From looking at the Cython tutorial this is how Cython is used to extend Python with compiled C modules.
- Separate Cython module is written in Python. Cython will convert this to a static compiled module as if written in C.
Use a setup.py
file to compile Cython module as a *.so
shared library. This shared library is actually a Python module.
python setup.py build_ext --inplace
From regular Python script import
the Cython module
import helloworld
Cython is normally used to extend Python with C. If on the other hand you want to embed Python code in your C program this is also possible.
Taking a look at the official docs on embedding Python into C is a good place to read up on first.
Here is a github project explaining how to do that, and a blog on how to do that.