cffi
Foreign Function Interface for Python calling C code.
Decision gist · record as of 2026-08-14
Yes. CFFI is actively maintained, widely used (top 100 PyPI), carries no security vulnerabilities, and has a permissive license. Install friction is moderate but manageable with prebuilt wheels for all major platforms. It's the right choice if you need to call C code from Python.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later; pycparser must be available as a runtime dependency.
- Medium install friction due to compiled wheels across many platforms; actively maintained with release 11 days ago and ongoing commits; requires Python 3.10 or later.
License · maintenance · safety
MIT-0 (permissive) — MIT-0 (permissive) license places no restrictions on use, modification, or distribution.
last release 2026-08-03 (11 days) · last repo commit 2026-08-03 · 275 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,303,772,314 downloads/mo, #12 on PyPI
Alternatives
Verify before relying
pip install cffi
from cffi import FFI
ffi = FFI()
ffi.cdef("int add(int a, int b);")
C = ffi.dlopen(None)
result = C.add(2, 3)- Whether pycparser is automatically installed as a dependency or must be installed separately
- Performance characteristics compared to alternative approaches
- Support for C++ code or only C
What it is and what it does
CFFI is a Foreign Function Interface library that lets Python code call C functions without writing C extension modules. It works by parsing C declarations you provide and generating the necessary glue code to bridge Python and C, handling type conversions and memory layout automatically. The package depends only on pycparser for parsing C syntax.
Typical use involves declaring C function signatures in Python, then calling them as if they were Python functions. CFFI supports both ABI mode (calling existing compiled libraries) and API mode (embedding C code). It's widely used in domains where performance-critical C libraries need to be accessible from Python.
Use it for
- Wrap existing C libraries for use in Python without writing C extensions
- Call performance-critical C functions from Python while maintaining readable calling conventions
- Embed C code snippets directly in Python projects for tight integration with compiled dependencies
- Build bindings for scientific or numerical libraries originally written in C
- Prototype C interoperability quickly without the overhead of writing full C extension modules
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
CFFI is actively maintained, widely used (top 100 PyPI), carries no security vulnerabilities, and has a permissive license. Install friction is moderate but manageable with prebuilt wheels for all major platforms. It's the right choice if you need to call C code from Python.
Install
cffi on PyPI
Before you install
Medium install friction due to compiled wheels across many platforms; actively maintained with release 11 days ago and ongoing commits; requires Python 3.10 or later.
Requires Python 3.10 or later; pycparser must be available as a runtime dependency.
License in practice
MIT-0 (permissive) license places no restrictions on use, modification, or distribution.
Quickstart
pip install cffi
from cffi import FFI
ffi = FFI()
ffi.cdef("int add(int a, int b);")
C = ffi.dlopen(None)
result = C.add(2, 3)
Verify before relying
- Whether pycparser is automatically installed as a dependency or must be installed separately
- Performance characteristics compared to alternative approaches
- Support for C++ code or only C
Package facts
| License | MIT-0 permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | 1 packagepycparser |
| Maintenance | Actively maintained 11 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,303,772,314 / month, #12 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Programming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: Free Threading :: 2 - BetaProgramming Language :: Python :: Implementation :: CPython |
Evidence: cffi-2.1.1-cp310-cp310-macosx_10_15_x86_64.whl; cffi-2.1.1-cp310-cp310-macosx_11_0_arm64.whl; cffi-2.1.1-cp310-cp310-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl; cffi-2.1.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; cffi-2.1.1-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl; cffi-2.1.1-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl; cffi-2.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; cffi-2.1.1-cp310-cp310-musllinux_1_2_aarch64.whl; cffi-2.1.1-cp310-cp310-musllinux_1_2_i686.whl; cffi-2.1.1-cp310-cp310-musllinux_1_2_x86_64.whl; cffi-2.1.1-cp310-cp310-win32.whl; cffi-2.1.1-cp310-cp310-win_amd64.whl; cffi-2.1.1-cp311-cp311-macosx_10_15_x86_64.whl; cffi-2.1.1-cp311-cp311-macosx_11_0_arm64.whl; cffi-2.1.1-cp311-cp311-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl; cffi-2.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; cffi-2.1.1-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl; cffi-2.1.1-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl; cffi-2.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; cffi-2.1.1-cp311-cp311-musllinux_1_2_aarch64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “python call c code”
- cffiCFFI enables Python code to call C functions directly by parsing C…
- pyan3Pyan3 performs static analysis on Python source code to generate call…
- cwrapcwrap is a Python wrapper around C code that builds on ctypes,…
Give your agent the search over MCP, or paste the wish link into any chat.
Similar packages
Provides type stubs for the cffi package, enabling static type checkers like mypy and pyright to understand and validate code that uses cffi for C foreign function interfaces.
Cython is a source code translator that compiles Python code to C, enabling optional static typing and direct C/C++ interoperability to generate efficient native extensions.
Install it if you need to optimize Python performance, wrap C/C++ libraries, or build fast native extensions.
pythonnet enables Python code to call .NET and Mono libraries directly, and allows .NET applications to embed and invoke Python code with full CLR interoperability.
Parses C header files and automates ctypes-based bindings to C libraries, handling macros, typedefs, structs, unions, enums, and function prototypes with automatic type conversion.
Install it if you need to call C libraries from Python and want to avoid hand-writing ctypes boilerplate; skip it if you prefer explicit control over bindings or are…
Provides a Python bridge to invoke C# Power Fx expressions through pythonnet and cffi, enabling Power Fx formula evaluation from Python code.
However, it is in early release (0.0.34), aging (235 days since last update), and lacks visible repository metadata, making its maintenance status unclear.
Provides direct Python bindings to the Pact FFI (Foreign Function Interface), exposing low-level C API functions for contract testing without higher-level abstraction.
See also pywin32-ctypes · brotlicffi · zstandard · PyQt5-sip