Cython

Cython
DeveloperRobert Bradshaw, Stefan Behnel, et al.
First appeared28 July 2007; 17 years ago (2007-07-28)[1]
Stable release3.0.11-1[2] Edit this on Wikidata (5 August 2024; 3 months ago (5 August 2024)) [±]
Preview release3.0.0 beta 2 (27 March 2023; 19 months ago (2023-03-27)[3]) [±]
Implementation languagePython
OSWindows, macOS, Linux
LicenseApache License 2.0
Filename extensions.pyx, .pxd, .pxi [4]
Websitecython.org Edit this at Wikidata
Influenced by
C, Python

Cython (/ˈsθɒn/) is a superset of the programming language Python, which allows developers to write Python code (with optional, C-inspired syntax extensions) that yields performance comparable to that of C.[5][6]

Cython is a compiled language that is typically used to generate CPython extension modules. Annotated Python-like code is compiled to C and then automatically wrapped in interface code, producing extension modules that can be loaded and used by regular Python code using the import statement, but with significantly less computational overhead at run time. Cython also facilitates wrapping independent C or C++ code into python-importable modules.

Cython is written in Python and C and works on Windows, macOS, and Linux, producing C source files compatible with CPython 2.6, 2.7, and 3.3 and later versions. The Cython source code that Cython compiles (to C) can use both Python 2 and Python 3 syntax, defaulting to Python 2 syntax in Cython 0.x and Python 3 syntax in Cython 3.x. The default can be overridden (e.g. in source code comment) to Python 3 (or 2) syntax. Since Python 3 syntax has changed in recent versions, Cython may not be up to date with the latest additions. Cython has "native support for most of the C++ language" and "compiles almost all existing Python code".[7]

Cython 3.0.0 was released on 17 July 2023.[8]

  1. ^ Behnel, Stefan (2008). "The Cython Compiler for C-Extensions in Python". EuroPython (28 July 2007: official Cython launch). Vilnius/Lietuva.
  2. ^ "Release 3.0.11-1". 5 August 2024. Retrieved 22 August 2024.
  3. ^ Cython Changelog, cython, 15 May 2023, retrieved 19 May 2023
  4. ^ "Language Basics — Cython 3.0.0a9 documentation". cython.readthedocs.io. Retrieved 9 September 2021.
  5. ^ "Cython - an overview — Cython 0.19.1 documentation". Docs.cython.org. Retrieved 21 July 2013.
  6. ^ Smith, Kurt (2015). Cython: A Guide for Python Programmers. O'Reilly Media. ISBN 978-1-4919-0155-7.
  7. ^ "FAQ · cython/cython Wiki". GitHub. Retrieved 11 January 2023.
  8. ^ "Cython Changelog". cython.org. Retrieved 21 July 2023.