About Anaconda Help Download Anaconda
  • 238582 total downloads
  • Last upload: 21 hours and 36 minutes ago

Installers

pip install

To install this package run one of the following:
pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython

Description

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.2.0a0 (2025-??-??)

Features added

  • Builtin exception types are now inferred. (Github issue https://github.com/cython/cython/issues/6908)

  • The list of known, inferred and optimised Python builtins was updated. range is now considered a type. ascii, bin, format, hex, oct were added as functions. (Github issue https://github.com/cython/cython/issues/6931)

  • The f-string syntax was extended according to PEP-701. (Github issue https://github.com/cython/cython/issues/5452)

  • The runtime Python dispatch for fused functions is substantially faster. (Github issues https://github.com/cython/cython/issues/1385, https://github.com/cython/cython/issues/6996)

  • Type checks on PEP-604 union types (int | None) are optimised into separate checks. (Github issue https://github.com/cython/cython/issues/6935)

  • Assignments to the PEP-604 union type float | None allow any suitable Python number as input and convert it to a Python float automatically. (Github issue https://github.com/cython/cython/issues/5750)

  • Item type inference was improved for looping over literals. (Github issue https://github.com/cython/cython/issues/6912)

  • Looping over literal sequences and strings now uses efficient C array looping if possible. (Github issue https://github.com/cython/cython/issues/6926)

  • Releasing the GIL from an unknown lock state is more efficient. (Github issue https://github.com/cython/cython/issues/6847)

  • cython.critical_section(PyMutex) now works, as with Python objects. (Github issue https://github.com/cython/cython/issues/6847)

  • bool(c_int/float/ptr) avoid passing through Python objects. (Github issue https://github.com/cython/cython/issues/7015)

  • Unused exceptions in except clauses are detected in some more cases to avoid their normalisation. (Github issue https://github.com/cython/cython/issues/7021)

  • Several improvements were made in freethreaded Python code. (Github issues https://github.com/cython/cython/issues/6936, https://github.com/cython/cython/issues/6939, https://github.com/cython/cython/issues/6949, https://github.com/cython/cython/issues/6984, https://github.com/cython/cython/issues/7011)

  • Several improvements were made for the Limited API. (Github issues https://github.com/cython/cython/issues/6959, https://github.com/cython/cython/issues/6991)

  • Some GIL-safe C-API wrappers were added to the libc/libcpp declarations. (Github issue https://github.com/cython/cython/issues/6829)

  • String and number constants use less storage space in the module. (Github issues https://github.com/cython/cython/issues/6971, https://github.com/cython/cython/issues/6978, https://github.com/cython/cython/issues/6986)

  • The managed dict/weakref support in CPython 3.12+ is used for internal types to benefit from future CPython optimisations here. (Github issue https://github.com/cython/cython/issues/6891)

  • Using NaN as exception return value is supported. (Github issues https://github.com/cython/cython/issues/6900, https://github.com/cython/cython/issues/6903)

  • Declarations for C++ condition variables were added. (Github issue https://github.com/cython/cython/issues/6836)

  • Declarations for the new PyUnstable_*() refcounting C-API functions in Py3.14 were added. (Github issue https://github.com/cython/cython/issues/6836)

  • Several improvements were made for the GraalPython support. Patch by Michael Šimáček. (Github issue https://github.com/cython/cython/issues/7074)

  • The annotated source HTML page shows alternating +/− markers to open/close lines. Patch by Kamil Monicz. (Github issue https://github.com/cython/cython/issues/7099)

  • Unicode 16.0.0 is used to parse identifiers. (Github issue https://github.com/cython/cython/issues/6836)

Bugs fixed

  • Special float exception values could generate invalid C code. (Github issues https://github.com/cython/cython/issues/6900, https://github.com/cython/cython/issues/6903)

  • References to the Python bool type could generate invalid C code. (Github issue https://github.com/cython/cython/issues/6902)

  • Vectorcalls could use needless temp assignments for self. (Github issue https://github.com/cython/cython/issues/6909)

  • Iterating over temporary memoryviews could crash Cython. (Github issue https://github.com/cython/cython/issues/7005)

  • Type casts on constants as part of numeric expressions could crash Cython. (Github issue https://github.com/cython/cython/issues/6779)

  • Indexing bytes failed to optimise in some cases. (Github issue https://github.com/cython/cython/issues/6997)

  • Pure mode type aliases like p_int or ulong leaked into some C type contexts, risking to conflict with user declarations. (Github issues https://github.com/cython/cython/issues/6922, https://github.com/cython/cython/issues/6339)

  • Boolean (emptyness) tests on builtin containers could fail to handle (unlikely) errors. (Github issue https://github.com/cython/cython/issues/7090)

  • The return type of bytes.join() was sometimes referred as plain object. (Github issue https://github.com/cython/cython/issues/6987)

  • Type inference could fail to understand prange() arguments. (Github issue https://github.com/cython/cython/issues/6974)

  • embedsignatures failed if lambda was used in function default arguments. (Github issue https://github.com/cython/cython/issues/6880)

  • An internal C function was not marked as static and leaked a linker symbol. (Github issue https://github.com/cython/cython/issues/6957)

  • Cython's tools and frontend scripts now use python3 instead of just python in their shebang line. Patch by Matti Picus. (Github issue https://github.com/cython/cython/issues/7053)

  • Includes all fixes as of Cython 3.1.3.

3.1.3 (2025-08-13):

  • Some method calls with 0 or 1 argument failed to use PyObject_VectorCallMethod().

  • Walrus assignments of literal Python integers could generate invalid C code. (Github issue https://github.com/cython/cython/issues/6989)

  • cython.pythread_type_lock (also used as fallback for cython.pymutex) could stall on heavily contended locks. (Github issue https://github.com/cython/cython/issues/6999)

  • C string arrays (not pointers) always coerced to the Python default string type, even on explicit casts to other string types. (Github issue https://github.com/cython/cython/issues/7020)

  • Unterminated \N{} character escapes in strings could unrail the parser. (Github issue https://github.com/cython/cython/issues/7056)

  • An internal C function was not marked as static and leaked a linker symbol. (Github issue https://github.com/cython/cython/issues/6957)

  • Some Unicode letters were not recognised as lexically valid name parts. (Github issue https://github.com/cython/cython/issues/7059)

  • Compatibility with PyPy3.8 was lost by accident.

  • The Linux binary wheels of 3.1.2 used SSSE3 CPU instructions which are not available on some CPUs. (Github issue https://github.com/cython/cython/issues/7038)


© 2025 Anaconda, Inc. All Rights Reserved. (v4.2.1) Legal | Privacy Policy