Closed Vipul-Cariappa closed 1 month ago
The right solution here is to have an ASR->ASR pass that takes the bind(Python) and replaces it with calls to Python C/API. This should not be hardwired into all the backends.
Yes. I am implementing this using an ASR to ASR pass. The python_bind.py
implements the ASR to ASR pass.
@Shaikh-Ubaid, @certik, Please have a look at this. This ASR pass currently supports, primitive datatypes, i.e. integers, unsigned integers, floats, and strings. I will add support for arrays in the following PRs. I have not tested this in interactive mode. I will also do it in the following PRs.
Otherwise it looks like the right approach, it seems you are doing the type translation to/from Python in the ASR->ASR pass already, which is perfect.
@Shaikh-Ubaid, I believe if the CI passes and these changes look good to you, then we can merge.
@certik The tests that use arrays (i.e. call into a CPython function that accepts arrays or returns an array) are skipped. Conversion from LPython arrays to CPython arrays (numpy array) needs to be implemented. I will do it in the next PR.
The right solution here is to have an ASR->ASR pass that takes the
bind(Python)
and replaces it with calls to Python C/API. This should not be hardwired into all the backends.If you think you can get something working with relatively short code, you can finish the PR, but I think having a pass is a better solution long term.