aeneas
aeneas copied to clipboard
Long term move from Python C extensions to CFFI
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.
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.
Current CFFI is awesome, but it has a fundamental problem w.r.t. the current C aeneas code: it does not support #include
statements. 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
.