Simple examples for extending Python with C/C++
Compile the extension module:
$ cd 01_hello_world
$ python3 setup.py build_ext --inplace
This can be done by make
, too:
$ make
Run a python script using the extension:
$ python3 ext01.py
A minimum extension module.
Use C/C++ pointer from Python.
Pass a filename string from Python to C/C++.
Return C/C++ data as an np.array.
Return a part of C/C++ data as an np.array.
Stop Python during long computation with Ctrl-C.