The C Foreign Function Interface for Python
open sourceMIT-0free
CFFI (C Foreign Function Interface) lets Python call almost any C code from C-like declarations you can often copy from header files or documentation. It works in ABI mode (loading a shared library at run time) or API mode (compiling a C extension), supports callbacks with extern "Python", structures, pointers, arrays and variadic calls, and can embed Python in C programs. It runs on CPython and PyPy. It was created by Armin Rigo and Maciej Fijalkowski.
Problems it solves
- call a C library from Python without writing a C extension by hand
- wrap a C shared library for Python
- use the same C bindings on CPython and PyPy
Features
- call C code from Python using C declarations
- ABI and API modes
- callbacks, structures, pointers and variadic calls
- embed Python in C programs
- CPython and PyPy