The most widely used Python to C compiler
Cython is a language that makes writing C extensions for Python as easy as Python itself. Cython is based on Pyrex, but supports more cutting edge functionality and optimizations.
The Cython language is very close to the Python language, but Cython additionally supports calling C functions and declaring C types on variables and class attributes. This allows the compiler to generate very efficient C code from Cython code.
This makes Cython the ideal language for wrapping external C libraries, and for fast C modules that speed up the execution of Python code.
You can support the Cython project via
Github Sponsors_ or
If you already have a C compiler, just run following command::
pip install Cython
the installation page_.
The original Pyrex program was licensed "free of restrictions" (see below). Cython itself is licensed under the permissive Apache License.
Want to contribute to the Cython project? Here is some
help to get you started_.
We are currently building the next great Cython edition:
Cython 3.0_. You can help us make the life of Python 3.x users easier.
Started as a project in the early 2000s, Cython has outlived
most other attempts_ at producing static compilers for the Python language.
Similar projects that have a relevance today include:
PyPy_, a Python implementation with a JIT compiler.
Numba_, a Python extension that features a JIT compiler for a subset of the language, based on the LLVM compiler infrastructure (probably best known for its
clangC compiler). It mostly targets numerical code that uses NumPy.
Pythran, a static Python-to-C++ extension compiler for a subset of the language, mostly targeted at numerical computation. Pythran can be (and is probably best) used as an additional `backend for NumPy code <https://cython.readthedocs.io/en/latest/src/userguide/numpypythran.html>`_ in Cython.
mypyc, a static Python-to-C extension compiler, based on the
mypystatic Python analyser. Like Cython's
pure Python mode_, mypyc can make use of PEP-484 type annotations to optimise code for static types.
Nuitka_, a static Python-to-C extension compiler.
In comparison to the above, Cython provides
Note that Cython used to ship the full version control repository in its source distribution, but no longer does so due to space constraints. To get the full source history from a downloaded source archive, make sure you have git installed, then step into the base directory of the Cython source distribution and type::
This is a development version of Pyrex, a language for writing Python extension modules.
For more info, take a look at:
Comments, suggestions, bug reports, etc. are most welcome!
Copyright stuff: Pyrex is free of restrictions. You may use, redistribute, modify and distribute modified versions.
The latest version of Pyrex can be found
| Greg Ewing, Computer Science Dept | University of Canterbury | Christchurch, New Zealand
A citizen of NewZealandCorp, a wholly-owned subsidiary of USA Inc.