ariovistus / pyd

Interoperability between Python and D
MIT License
158 stars 32 forks source link

pyd vs cython #66

Closed liveresume closed 7 years ago

liveresume commented 7 years ago

I am wondering what the difference would be between:

The way I see it:

Just picking up with Python+D weighing my options and looking for clarification.

ariovistus commented 7 years ago

Haven't really used cython, but all else being equal, I would tend to expect code produced by it to be faster than embedding python in d, if only because you aren't running the python through an interpreter. At the end of the day, both are going to be hitting the python C API. cython is probably more efficient at that.

I think the biggest difference between your two strategies would be integration of the results with your d code. With cython, it would be on you to write the headers for your shared objects and deal with data conversion and exceptions across that boundary. pyd does that stuff for you, but that might not matter if the interface between your python code and d code is small. also, it might be easier to shift speed critical sections of code from python to d with pyd than cython.

bryaan commented 7 years ago

@ariovistus Thanks for the info. Cython actually produces header files so it should be a breeze to embed. Also the data conversion should be unnecessary since Cython uses C types rather than Python types.

liveresume commented 7 years ago

@ariovistus Would appreciate your input after you've had time to checkout cython.

Maybe it's within reason to note on readme that pyd is more for D in Python rather than vice-versa?

ariovistus commented 7 years ago

No, pyd works fine with python in d. better than the reverse, actually, if your measure is the number of D compilers that can even produce shared libraries.

liveresume commented 7 years ago

@ariovistus I see your point. The big difference for me is that Cython is much faster than Python.