Registry / data / cython

cython

JSON →
library3.3.0pypypi✓ verified 10d ago

Cython is an optimizing static compiler for both the Python programming language and the extended Cython programming language, making writing C extensions for Python as easy as Python itself. Current version: 3.2.4. Release cadence: Regular updates with active development and maintenance.

pip install cython
INSTALL
IMPORT
SIG · CYTHON
C
cython
datapythonv3.3.0
Install
2.7s avg
Import
23ms
Disk
31MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.026s · 31.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.7s · import 0.020s · 32MB
31MB installed
● package 31MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cython
import cython
Necessary for using Cython-specific features

A simple example demonstrating the use of Cython's cfunc decorator to define a C function in Python.

import cython @cython.cfunc @cython.exceptval(-1) def add(int x, int y): return x + y print(add(2, 3))
cython --version
Debug
Known issues
breakingSupport for Python 2.7 - 3.7 was removed in Cython 3.3.0a0, along with large chunks of legacy code.
fix
Upgrade to Python 3.8 or later.
affects: 3.3.0a0
gotchaUsing the pure Python syntax for static type declarations requires a recent Cython 3 release due to significant improvements over the 0.29.x releases.
fix
Upgrade to the latest Cython 3 release.
affects: 0.29.x
breakingThe script uses Cython-specific C-style parameter declarations (e.g., `int x`), which are invalid in standard Python and will result in a `SyntaxError`. This syntax is only recognized by the Cython compiler.
fix
Compile the script with Cython or rewrite the code using standard Python type hints (e.g., `x: int`).
affects: N/A (occurs when executing Cython syntax in a standard Python interpreter)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'Cython'
This error occurs when the Cython package itself is not installed in the Python environment you are using, or it's installed in a different environment or Python version.
fix
Ensure Cython is installed in your active Python environment by running: `pip install Cython`
error: Microsoft Visual C++ 14.0 or greater is required.
On Windows, compiling Cython extensions (which generate C/C++ code) requires a compatible C++ compiler, typically provided by the Microsoft C++ Build Tools or a Visual Studio installation.
fix
Install the 'Desktop development with C++' workload from Visual Studio Installer, or specifically the 'Microsoft C++ Build Tools' (available at visualstudio.microsoft.com/visual-cpp-build-tools/). Ensure your environment variables are correctly set for the compiler.
AttributeError: type object 'your_module.YourCythonClass' has no attribute '__reduce_cython__'
This error typically arises when trying to pickle or copy a Cython extension type that does not have proper serialization methods (`__reduce_cython__` and `__setstate_cython__`) defined, often after upgrading Cython or Python, or when using libraries like PyInstaller.
fix
For pickling custom extension types, you need to explicitly implement `__reduce_cython__` and `__setstate_cython__` methods in your Cython class, or use the `@cython.auto_pickle(True)` decorator if applicable (though explicit implementation is generally safer for complex types).
Segmentation fault
A segmentation fault in Cython code usually indicates a low-level memory access error, such as reading or writing beyond allocated memory bounds, using uninitialized C pointers, or incorrect memory management when interacting with C libraries.
fix
Debug the Cython code to identify memory-related issues. Common steps include enabling Cython directives like `boundscheck=True` and `wraparound=True` during development, carefully managing C pointers and `malloc`/`free`, and using tools like `gdb` for C-level debugging.
Upgrade
Version history
3.3.0latest on PyPI · released Aug 22, 2026
Audit
Dependencies
setuptoolsrequiredRequired for building Cython extensions
Agent activity
25 hits · last 30 days
node
20
Resources