Cython: C-Extensions for Python
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.
Warnings
- breaking Support for Python 2.7 - 3.7 was removed in Cython 3.3.0a0, along with large chunks of legacy code.
- gotcha Using the pure Python syntax for static type declarations requires a recent Cython 3 release due to significant improvements over the 0.29.x releases.
Install
-
pip install cython
Imports
- cython
import cython
Quickstart
import cython
@cython.cfunc
@cython.exceptval(-1)
def add(int x, int y):
return x + y
print(add(2, 3))