Technically, f2py
can also wrap C code for us, but there are more efficient ways to perform this task. For instance, if we need to interface a very large library of C functions, the preferred method is
Simplified Wrapper and Interface Generator (SWIG). To wrap C++ code, depending on features required and the method of interacting with Python, we have several methods such as SWIG or f2py
again, but also PyCXX, Boost.Python, or the SciPy module, weave
. When C compilers are not available (and thus linking extensive libraries is not possible in the usual way), we use ctypes. Whenever we are going to use NumPy/SciPy code, and we seek fast solutions to our wrapping/binding, the most two common ways to interact with C/C++ are usually through the Python/C API, or through the weave
package.
All the methods briefly enumerated here would require an entire monograph to describe at length the methodology of binding the nuisances of the wrapping depending on systems and requirements, and the caveats...