single |
The Cython language makes writing C extensions for the Python language as
easy as Python itself. Cython is a source code translator based on Pyrex_,
but supports more cutting edge functionality and optimizations.
The Cython language is a superset of the Python language (almost all Python
code is also valid Cython code), but Cython additionally supports optional
static typing to natively call C functions, operate with C++ classes and
declare fast 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 writing glue code for external
C/C++ libraries, and for fast C modules that speed up the execution of
Python code.
The newest Cython release can always be downloaded from
https://cython.org/.
Unpack the tarball or zip file, enter the directory, and then run::
pip install .
Note that for one-time builds, e.g. for CI/testing, on platforms that are
not
covered by one of the wheel packages provided on PyPI *and* the pure Python
wheel
that we provide is not used, it is substantially faster than a full source
build
to install an uncompiled (slower) version of Cython with::
NO_CYTHON_COMPILE=true pip install .
.. _Pyrex: https://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/
3.1.0 (2025-05-08)
==================
Features added
--------------
3.1.0 rc 2 (2025-05-07):
* Declarations for C++ ``std::stop_token were added as libcpp.stop_token``
to provide
additional low-level synchronisation primitives also in the light of
free-threading Python.
(Github issue https://github.com/cython/cython/issues/6820)
* The generation of the shared module now happens automatically from
``cythonize() in a
setuptools build if a corresponding Extension`` has been configured.
This avoids an additional step outside of the ``setup.py or pip wheel``
run.
(Github issue https://github.com/cython/cython/issues/6842)
3.1.0 rc 1 (2025-05-01):
* ``cython.pymutex provides a fast mutex by wrapping the new PyMutex``
feature of recent
CPython versions (including free-threading) and falls back to PyThread
locks in older Pythons.
(Github issue https://github.com/cython/cython/issues/6579)
* A new directive ``subinterpreters_compatible=shared_gil/own_gil`` was
added to allow modules
to declare support for subinterpreters.
(Github issue https://github.com/cython/cython/issues/6513)
* ``divmod()`` is also optimised for C floating point types and can be
called on C number types
without holding the GIL.
(Github issue https://github.com/cython/cython/issues/6801)
* New C++ declarations were added.
(Github issues https://github.com/cython/cython/issues/6625,
https://github.com/cython/cython/issues/6731)
* embedsignature now works for special methods (if they have a docstring).
(Github issue https://github.com/cython/cython/issues/1577)
3.1.0 beta 1 (2025-04-03):
* Global ``cdef const …`` variables are supported.
(Github issue https://github.com/cython/cython/issues/6542)
* A new context manager / function decorator ``cython.critical_section``
was added
wrapping Python's critical section C-API feature.
(Github issues https://github.com/cython/cython/issues/6516,
https://github.com/cython/cython/issues/6577)
* Some common Cython-internal code (currently only memoryview related) can
now be extracted
into a shared extension module to reduce the installed overall size of a
package with many
Cython compiled modules.
(Github issue https://github.com/cython/cython/issues/2356)
* The type of prange loop targets is now inferred.
(Github issue https://github.com/cython/cython/issues/6585)
* Extracting keyword arguments is faster in some cases.
|