aeneas icon indicating copy to clipboard operation
aeneas copied to clipboard

Long term move from Python C extensions to CFFI

Open pettarin opened this issue 8 years ago • 2 comments

Today I tried running aeneas under PyPy (Python 2.7.10 branch). Everything seems working, except cdtw and cmfcc that gets compiled, but they do not import, producing the following error: AttributeError: _ARRAY_API not found ... ImportError: numpy.core.multiarray failed to import, both with NumPyPy and upstream NumPy.

Asking on their IRC channel, they strongly suggest to switch to CFFI, as the C API is not the preferred mechanism of PyPy for calling C code.

So, for the long run, it might be worth considering switching to CFFI or supporting it along side C extensions.

pettarin avatar Aug 05 '16 20:08 pettarin

Actually now I have a venv with PyPy, and aeneas works as expected, including the C extensions. (Perhaps I had a caching problem with the whl when using pip.) However, it looks slightly slower than CPython. Yet, I believe CFFI is still worth some thinking.

pettarin avatar Aug 06 '16 12:08 pettarin

Current CFFI is awesome, but it has a fundamental problem w.r.t. the current C aeneas code: it does not support #includestatements. Since e.g. cint.h is included by the other C source files, using cffi would require a workaround and/or to rewrite those C includes.

Another problem is that also #if or #def are not supported, fact that again impacts cint.

readbeyond avatar Dec 13 '16 09:12 readbeyond