Embedding to Python
Nanguage opened this issue · 2 comments
It's possible to embedding seq-lang to Python? Just like the numba and taichi.
The syntax of seq-lang is very similar to Python, so I think maybe it's possible to compile the source code in a Python function to seq-lang, for example:
@seq_lang
def check_prime(n):
# this part in "seq-lang scope", it will compile to seq lang and get high performance
if n > 1:
for i in range(2, n):
if n % i == 0:
return False
return True
else:
return False
# this part run in "Python scope", run slow but could interact with other Python library
n = 1009
print(n, 'is', 'a' if check_prime(n) else 'not a', 'prime')
If it's possible, it's will more convenient for Python users in their daily work.
Hi @Nanguage, thanks for the suggestion. This is definitely something on our todo list. In theory it shouldn't be too difficult, and we have an idea of how to implement it. We're in the process now of generalizing/expanding Seq w.r.t. Python compatibility and interoperability, and plan to look more into this soon.
Just saw the paper and was intrigued, and this issue was top of my mind. Calling Python from Seq is great, but calling Seq from Python would be even better :D That way I can keep my existing Python pipeline and only speed up the parts that are particularly painful.