NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #11 most downloaded on PyPI
Foreign Function Interface for Python calling C code.
Last release 2 months ago
03 Aug 2026
Release timing varies
gaps range from 2 weeks to 1.2 years
Some releases are documented
notes for 33 of the last 60 stable releases
1 version withdrawn
withdrawn after publishing
14 years old
80 releases · first in 2012
Minimize internal Python API usage for interpreter and thread state sampling where possible. Avoids breaking ABI change in Python >= 3.15.0b4 ( #269 )
Full Changelog: v2.1.0...v2.1.1
Added support for Python 3.15 and support for C extensions generated by CFFI to target the new abi3t free-threaded ABI.
abi3t free-threaded ABI.cffi-gen-src CLI to generate CFFI C extension source for alternate build backend support.__delitem__.One column per quarter.
Add CPython free-threaded support (3.14t+ only) - huge thanks to the folks at Quansight Labs for all the work to get this one sorted!
Full Changelog: v1.17.1...v2.0.0
Add CPython free-threaded support (3.14t+ only).
Full Changelog: v1.17.1...v2.0.0b1
Fix failing distutils.msvc9compiler imports under Windows ( #118 ).
distutils.msvc9compiler imports under Windows (#118).ffibuilder.emit_python_code() and ffibuiler.emit_c_code() accept file-like objects (#115).ffiplatform calls are bypassed by ffibuilder.emit_python_code() and ffibuilder.emit_c_code() (#81).Full Changelog: v1.17.0...v1.17.1
Free-threaded CPython builds (i.e. python3.13t and the 3.13t ABI) are not currently supported.
python3.13t and the 3.13t ABI) are not currently supported.fn = lib.myfunc, you get an object of a special type for performance<cdata 'C-function-type'>. Before version 1.17ffi.addressof(lib, "myfunc") in order to get a real <cdata> object,&myfuncmyfunc. In version 1.17, the special objectlib.myfunc can now be passed in many places where CFFI expects<cdata> object. For example, you can now passffi.cast() or ffi.typeof() on it.Full Changelog: v1.16.0...v1.17.0
In API mode, when you get a function from a C library by writing fn = lib.myfunc, you get an object of a special type for performance reasons, instead
Add support for Python 3.12. With the removal of distutils from Python 3.12, projects using CFFI features that depend on distutils at runtime must add
distutils from Python 3.12, projectsdistutils at runtime must add a dependency onsetuptools to function under Python 3.12+. CFFI does not declare a runtime setuptoolssetuptools is now a required build dependency.python_requires metadata for Python 3.8+. This allows unsupported Pythonssrc/; a more standard layout that also enables CI to more easilyFix packaging issue in v1.16.0rc1.
src/ layout) so packaging tests can properly detect similar issues in the future.Full Changelog: v1.16.0rc1...v1.16.0rc2
Add support for Python 3.12. With the removal of distutils from Python 3.12, projects using CFFI features that depend on distutils at runtime must add
distutils from Python 3.12, projectsdistutils at runtime must add a dependency onsetuptools to function under Python 3.12+. CFFI does not declare a runtime setuptoolspython-cffi/cffi on GitHub.setuptools is now a required build dependency.python_requires metadata for Python 3.8+. This allows unsupported PythonsPyObject_GC_UnTrack to avoid ResourceWarning 15c4b71(retroactive GitHub release for current stable version 1.15.1)
(retroactive GitHub release for current stable version 1.15.1)
Full Changelog: https://github.com/python-cffi/cffi/compare/v1.15.0...v1.15.1
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
- Fix for nested struct types that end in a var-sized array (#405).
Fix for nested struct types that end in a var-sized array (#405).
Add support for using U and L characters at the end of integer constants in ffi.cdef() (thanks Guillaume).
More 3.8 fixes.
- Added temporary workaround to compile on CPython 3.8.0a2.
Added temporary workaround to compile on CPython 3.8.0a2.
- CPython 3 on Windows: we again no longer compile with Py_LIMITED_API by default because such modules still cannot be used with virtualenv. The probl
CPython 3 on Windows: we again no longer compile with Py_LIMITED_API by default because such modules still cannot be used with virtualenv. The problem is that it doesn’t work in CPython <= 3.4, and for technical reason we can’t enable this flag automatically based on the version of Python.
Like before, Issue #350 mentions a workaround if you still want the Py_LIMITED_API flag and either you are not concerned about virtualenv or you are sure your module will not be used on CPython <= 3.4: pass define_macros=[("Py_LIMITED_API", None)] as a keyword to the ffibuilder.set_source() call.
Nothing published for this version
- Issue #357 : fix ffi.emit_python_code() which generated a buggy Python file if you are using a struct with an anonymous union field or vice-versa.
Issue #357 : fix ffi.emit_python_code() which generated a buggy Python file if you are using a struct with an anonymous union field or vice-versa.
Windows: ffi.dlopen() should now handle unicode filenames.
ABI mode: implemented ffi.dlclose() for the in-line case (it used to be present only in the out-of-line case).
Fixed a corner case for setup.py install --record=xx --root=yy with an out-of-line ABI module. Also fixed Issue #345 .
More hacks on Windows for running CFFI’s own setup.py .
Issue #358 : in embedding, to protect against (the rare case of) Python initialization from several threads in parallel, we have to use a spin-lock. On CPython 3 it is worse because it might spin-lock for a long time (execution of Py_InitializeEx() ). Sadly, recent changes to CPython make that solution needed on CPython 2 too.
CPython 3 on Windows: we no longer compile with Py_LIMITED_API by default because such modules cannot be used with virtualenv. Issue #350 mentions a workaround if you still want that and are not concerned about virtualenv: pass define_macros=[("Py_LIMITED_API", None)] as a keyword to the ffibuilder.set_source() call.
- Windows: reverted linking with python3.dll , because virtualenv does not make this DLL available to virtual environments for now. See Issue #355 . O
Windows: reverted linking with python3.dll , because virtualenv does not make this DLL available to virtual environments for now. See Issue #355 . On Windows only, the C extension modules created by cffi follow for now the standard naming scheme foo.cp36-win32.pyd , to make it clear that they are regular CPython modules depending on python36.dll .
- Fix on CPython 3.x: reading the attributes __loader__ or __spec__ from the cffi-generated lib modules gave a buggy SystemError. (These attributes ar
Fix on CPython 3.x: reading the attributes loader or spec from the cffi-generated lib modules gave a buggy SystemError. (These attributes are always None, and provided only to help compatibility with tools that expect them in all modules.)
More Windows fixes: workaround for MSVC not supporting large literal strings in C code (from ffi.embedding_init_code(large_string) ); and an issue with Py_LIMITED_API linking with python35.dll/python36.dll instead of python3.dll .
Small documentation improvements.
- Fix Windows issue with managing the thread-state on CPython 3.0 to 3.5
Fix Windows issue with managing the thread-state on CPython 3.0 to 3.5
- Fix tests, remove deprecated C API usage
Fix tests, remove deprecated C API usage
Fix (hack) for 3.6.0/3.6.1/3.6.2 giving incompatible binary extensions (cpython issue #29943 )
Fix for 3.7.0a1+
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
- When passing a void * argument to a function with a different pointer type, or vice-versa, the cast occurs automatically, like in C. The same occurs
When passing a void * argument to a function with a different pointer type, or vice-versa, the cast occurs automatically, like in C. The same occurs for initialization with ffi.new() and a few other places. However, I thought that char * had the same property—but I was mistaken. In C you get the usual warning if you try to give a char * to a char ** argument, for example. Sorry about the confusion. This has been fixed in CFFI by giving for now a warning, too. It will turn into an error in a future version.
- Issue #283: fixed ffi.new() on structures/unions with nested anonymous structures/unions, when there is at least one union in the mix. When initiali
Issue #283: fixed ffi.new() on structures/unions with nested anonymous structures/unions, when there is at least one union in the mix. When initialized with a list or a dict, it should now behave more closely like the { } syntax does in GCC.
Nothing published for this version
Nothing published for this version
- Fix 1.5.1 for Python 2.6.
Fix 1.5.1 for Python 2.6.
- A few installation-time tweaks (thanks Stefano!)
A few installation-time tweaks (thanks Stefano!)
Issue #245: Win32: __stdcall was never generated for extern "Python" functions
Issue #246: trying to be more robust against CPython’s fragile interpreter shutdown logic
- Support for using CFFI for embedding .
Support for using CFFI for embedding .
Nothing changed from v1.4.1.
Nothing changed from v1.4.1.
- Fix the compilation failure of cffi on CPython 3.5.0. (3.5.1 works; some detail changed that makes some underscore-starting macros disappear from vi
Fix the compilation failure of cffi on CPython 3.5.0. (3.5.1 works; some detail changed that makes some underscore-starting macros disappear from view of extension modules, and I worked around it, thinking it changed in all 3.5 versions—but no: it was only in 3.5.1.)
- A better way to do callbacks has been added (faster and more portable, and usually cleaner). It is a mechanism for the out-of-line API mode that rep
A better way to do callbacks has been added (faster and more portable, and usually cleaner). It is a mechanism for the out-of-line API mode that replaces the dynamic creation of callback objects (i.e. C functions that invoke Python) with the static declaration in cdef() of which callbacks are needed. This is more C-like, in that you have to structure your code around the idea that you get a fixed number of function pointers, instead of creating them on-the-fly.
ffi.compile() now takes an optional verbose argument. When True , distutils prints the calls to the compiler.
ffi.compile() used to fail if given sources with a path that includes ".." . Fixed.
ffi.init_once() added. See docs .
dir(lib) now works on libs returned by ffi.dlopen() too.
Cleaned up and modernized the content of the demo subdirectory in the sources (thanks matti!).
ffi.new_handle() is now guaranteed to return unique void * values, even if called twice on the same object. Previously, in that case, CPython would return two cdata objects with the same void * value. This change is useful to add and remove handles from a global dict (or set) without worrying about duplicates. It already used to work like that on PyPy. This change can break code that used to work on CPython by relying on the object to be kept alive by other means than keeping the result of ffi.new_handle() alive. (The corresponding warning in the docs of ffi.new_handle() has been here since v0.8!)
- The optional typedefs ( bool , FILE and all Windows types) were not always available from out-of-line FFI objects.
The optional typedefs ( bool , FILE and all Windows types) were not always available from out-of-line FFI objects.
Opaque enums are phased out from the cdefs: they now give a warning, instead of (possibly wrongly) being assumed equal to unsigned int . Please report if you get a reasonable use case for them.
Some parsing details, notably volatile is passed along like const and restrict . Also, older versions of pycparser misparse some pointer-to-pointer types like char * const * : the “const” ends up at the wrong place. Added a workaround.
- Pull request #64: out-of-line API mode: we can now declare floating-point types with typedef float... foo_t; . This only works if foo_t is a float o
Added ffi.memmove() .
Pull request #64: out-of-line API mode: we can now declare floating-point types with typedef float... foo_t; . This only works if foo_t is a float or a double, not long double .
Issue #217: fix possible unaligned pointer manipulation, which crashes on some architectures (64-bit, non-x86).
Issues #64 and #126: when using set_source() or verify() , the const and restrict keywords are copied from the cdef to the generated C code; this fixes warnings by the C compiler. It also fixes corner cases like typedef const int T; T a; which would previously not consider a as a constant. (The cdata objects themselves are never const .)
Win32: support for __stdcall . For callbacks and function pointers; regular C functions still don’t need to have their calling convention declared.
Windows: CPython 2.7 distutils doesn’t work with Microsoft’s official Visual Studio for Python, and I’m told this is not a bug . For ffi.compile(), we removed a workaround that was inside cffi but which had unwanted side-effects. Try saying import setuptools first, which patches distutils…
Nothing changed from v1.2.0.
Nothing changed from v1.2.0.
- Out-of-line mode: int a[][...]; can be used to declare a structure field or global variable which is, simultaneously, of total length unknown to the
Out-of-line mode: int a[][...]; can be used to declare a structure field or global variable which is, simultaneously, of total length unknown to the C compiler (the a[] part) and each element is itself an array of N integers, where the value of N is known to the C compiler (the int and [...] parts around it). Similarly, int a[5][...]; is supported (but probably less useful: remember that in C it means int (a[5])[...]; ).
PyPy: the lib.some_function objects were missing the attributes name , module and doc that are expected e.g. by some decorators-management functions from functools .
Out-of-line API mode: you can now do from _example.lib import x to import the name x from _example.lib , even though the lib object is not a standard module object. (Also works in from _example.lib import * , but this is even more of a hack and will fail if lib happens to declare a name called all . Note that * excludes the global variables; only the functions and constants make sense to import like this.)
lib.dict works again and gives you a copy of the dict—assuming that lib has got no symbol called precisely dict . (In general, it is safer to use dir(lib) .)
Out-of-line API mode: global variables are now fetched on demand at every access. It fixes issue #212 (Windows DLL variables), and also allows variables that are defined as dynamic macros (like errno ) or __thread -local variables. (This change might also tighten the C compiler’s check on the variables’ type.)
Issue #209: dereferencing NULL pointers now raises RuntimeError instead of segfaulting. Meant as a debugging aid. The check is only for NULL: if you dereference random or dead pointers you might still get segfaults.
Issue #152: callbacks : added an argument ffi.callback(..., onerror=...) . If the main callback function raises an exception and onerror is provided, then onerror(exception, exc_value, traceback) is called. This is similar to writing a try: except: in the main callback function, but in some cases (e.g. a signal) an exception can occur at the very start of the callback function—before it had time to enter the try: except: block.
Issue #115: added ffi.new_allocator() , which officializes support for alternative allocators .
- ffi.gc() : fixed a race condition in multithreaded programs introduced in 1.1.1
ffi.gc() : fixed a race condition in multithreaded programs introduced in 1.1.1
- Out-of-line mode: ffi.string() , ffi.buffer() and ffi.getwinerror() didn’t accept their arguments as keyword arguments, unlike their in-line mode eq
Out-of-line mode: ffi.string() , ffi.buffer() and ffi.getwinerror() didn’t accept their arguments as keyword arguments, unlike their in-line mode equivalent. (It worked in PyPy.)
Out-of-line ABI mode: documented a restriction of ffi.dlopen() when compared to the in-line mode.
ffi.gc() : when called several times with equal pointers, it was accidentally registering only the last destructor, or even none at all depending on details. (It was correctly registering all of them only in PyPy, and only with the out-of-line FFIs.)
- Out-of-line API mode: we can now declare integer types with typedef int... foo_t; . The exact size and signedness of foo_t is figured out by the com
Out-of-line API mode: we can now declare integer types with typedef int... foo_t; . The exact size and signedness of foo_t is figured out by the compiler.
Out-of-line API mode: we can now declare multidimensional arrays (as fields or as globals) with int n[...][...] . Before, only the outermost dimension would support the ... syntax.
Out-of-line ABI mode: we now support any constant declaration, instead of only integers whose value is given in the cdef. Such “new” constants, i.e. either non-integers or without a value given in the cdef, must correspond to actual symbols in the lib. At runtime they are looked up the first time we access them. This is useful if the library defines extern const sometype somename; .
ffi.addressof(lib, "func_name") now returns a regular cdata object of type “pointer to function”. You can use it on any function from a library in API mode (in ABI mode, all functions are already regular cdata objects). To support this, you need to recompile your cffi modules.
Issue #198: in API mode, if you declare constants of a struct type, what you saw from lib.CONSTANT was corrupted.
Issue #196: ffi.set_source("package._ffi", None) would incorrectly generate the Python source to package._ffi.py instead of package/_ffi.py . Also fixed: in some cases, if the C file was in build/foo.c , the .o file would be put in build/build/foo.o .
- Same as 1.0.2, apart from doc and test fixes on some platforms.
Same as 1.0.2, apart from doc and test fixes on some platforms.
- Variadic C functions (ending in a “…” argument) were not supported in the out-of-line ABI mode. This was a bug—there was even a (non-working) exampl
Variadic C functions (ending in a “…” argument) were not supported in the out-of-line ABI mode. This was a bug—there was even a (non-working) example doing exactly that!
Variadic C functions (ending in a "..." argument) were not supported in the out-of-line ABI mode. This was a bug---there was even a (non-working) example doing exactly that!
- ffi.set_source() crashed if passed a sources=[..] argument. Fixed by chrippa on pull request #60.
ffi.set_source() crashed if passed a sources=[..] argument. Fixed by chrippa on pull request #60.
Issue #193: if we use a struct between the first cdef() where it is declared and another cdef() where its fields are defined, then this definition was ignored.
Enums were buggy if you used too many “…” in their definition.
- for API level , which used to be with ffi.verify() , now deprecated
The main news item is out-of-line module generation:
for ABI level , with ffi.dlopen()
for API level , which used to be with ffi.verify() , now deprecated
(this page will list what is new from all versions from 1.0.0 forward.)
The main news item is out-of-line module generation:
for ABI level, with ffi.dlopen()
for API level, which used to be with ffi.verify(), now deprecated
(this page will list what is new from all versions from 1.0.0 forward.)
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →