An example of using CFFI to wrap a C library for use with numpy, accompanied by a benchmark to evaluate the performance benefits.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Note: things will probably work fine with older versions of both numpy and cffi than the ones in requirements.txt, I just fixed the ones that happened to be installed for me.
Run C tests:
gcc -Wall -o mylib_test mylib_test.c mylib.c
./mylib_test
Build the C extension:
python mylib_extension_build.py
Run Python tests:
python -m unittest myutils_test.py
Run the benchmark:
python benchmark.py