Cython: Difference between revisions

Content deleted Content added
Addbot (talk | contribs)
m Bot: Migrating 5 interwiki links, now provided by Wikidata on d:q975594 (Report Errors)
m Copyedit
 
(242 intermediate revisions by more than 100 users not shown)
Line 1:
{{Distinguish|CPython}}
:''Not to be confused with [[CPython]].''
{{Use dmy dates|date=February 2014}}
{{Infobox software
{{short description|Programming language}}
| name = Cython
{{Infobox programming language
| title =
| name = Cython
| logo = [[File:Cython-logo.svg|frameless]]
| logo = Cython logo.svg
| screenshot = <!-- [[File: ]] -->
| developer = Robert Bradshaw, Stefan Behnel, et al.
| caption =
| released = {{Start date and age|df=yes|2007|07|28}}<ref>{{cite web |url=https://www.behnel.de/cythonEP2008/cython-ep2008.html |type=28 July 2007: official Cython launch |title=The Cython Compiler for C-Extensions in Python |last=Behnel |first=Stefan |work=EuroPython |date=2008 |publisher=Vilnius/Lietuva}}</ref>
| collapsible =
| license = [[Apache License 2.0]]
| author =
| programming language = [[Python (programming language)|Python]]
| developer = Robert Bradshaw, Stefan Behnel, et al.
| influenced_by = [[C (programming language)|C]], [[Python (programming language)|Python]]
| released = {{Start date|2007|07|28|df=yes/no}}<ref>[http://www.behnel.de/cythonEP2008/cython-ep2008.html 28th July 2007: official Cython launch], The Cython Compiler for C-Extensions in Python, Dr. Stefan Behnel, EuroPython 2008, Vilnius/Lietuva</ref>
| operating_system = [[Windows]], [[macOS]], [[Linux]]
| discontinued =
| file_ext = .pyx, .pxd, .pxi<ref>{{Cite web |title=Language Basics — Cython 3.0.0a9 documentation |url=https://cython.readthedocs.io/en/latest/src/userguide/language_basics.html#cython-file-types |access-date=9 September 2021 |website=cython.readthedocs.io}}</ref>
| latest release version =
| website = {{official URL}}
| latest release date = <!-- {{Start date and age|YYYY|MM|DD|df=yes/no}} -->
| latest preview version =
| latest preview date = <!-- {{Start date and age|YYYY|MM|DD|df=yes/no}} -->
| frequently updated = yes<!-- Release version update? Don't edit this page, just click on the version number! -->
| programming language =
| operating system = [[Cross-platform]]
| platform =
| size =
| language =
| status =
| genre = [[Programming language]]
| license = [[Apache License]]
| website = {{URL|http://cython.org}}
}}
 
'''Cython''' ({{IPAc-en|ˈ|s|aɪ|θ|ɒ|n}}) is a [[superset]] of the programming language [[Python (programming language)|Python]], which allows developers to write Python code (with optional, C-inspired syntax extensions) that yields performance comparable to that of [[C (programming language)|C]].<ref>{{cite web |url=https://docs.cython.org/src/quickstart/overview.html |title=Cython - an overview — Cython 0.19.1 documentation |publisher=Docs.cython.org |access-date=21 July 2013}}</ref><ref>{{cite book |last1=Smith |first1=Kurt |title=Cython: A Guide for Python Programmers |date=2015 |publisher=[[O'Reilly Media]] |isbn=978-1-4919-0155-7 |url=https://shop.oreilly.com/product/0636920033431.do}}</ref>
The '''Cython''' [[programming language]] is a superset of [[Python (programming language)|Python]] with a [[foreign function interface]] for invoking [[C (programming language)|C]]/[[C++]] [[subroutine|routines]] and the ability to declare the [[static type]] of routine parameters, local variables, subroutine results, and class attributes.<ref>http://docs.cython.org/src/quickstart/overview.html</ref>
 
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 [[wrapper library|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 (program lifecycle phase)|run time]]. Cython also facilitates wrapping independent C or C++ code into Python-importable modules.
== Overview ==
Cython is a compiled language that generates CPython extension modules. These extension modules can then be loaded and used by regular Python code using the import statement. Cython is written in Python and works on [[Microsoft Windows|Windows]], [[Linux]], and [[Mac OS X]], producing source files compatible with Python 2.4 through 3.3.
 
Cython is written in Python and C and works on [[Microsoft Windows|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".<ref>{{Cite web |title=FAQ · cython/cython Wiki |url=https://github.com/cython/cython |access-date=11 January 2023 |website=GitHub |language=en}}</ref>
== Hello World ==
[[File:Cython CPython Ext Module Workflow.png|thumb|Hello World in Cython]]
 
Cython 3.0.0 was released on 17 July 2023.<ref>{{Cite web |title=Cython Changelog |url=https://cython.readthedocs.io/en/latest/src/changes.html |access-date=21 July 2023 |website=cython.org |language=en}}</ref>
Cython has an unusually involved [[hello world]] program because it interfaces with the Python C API and the <code>distutils</code> extension building facility. At least three files are required for a basic project:
 
== Design ==
* A <code>setup.py</code> file to invoke the <code>distutils</code> build process that generates the extension module
Cython works by producing a standard Python module. However, the behavior differs from standard Python in that the module code, originally written in Python, is translated into C. While the resulting code is fast, it makes many calls into the CPython interpreter and CPython standard libraries to perform actual work. Choosing this arrangement saved considerably on Cython's development time, but modules have a dependency on the Python interpreter and standard library.
* A main python program to load the extension module
* Cython source file(s)
 
Although most of the code is C-based, a small stub loader written in interpreted Python is usually required (unless the goal is to create a loader written entirely in C, which may involve work with the undocumented internals of CPython). However, this is not a major problem due to the presence of the Python interpreter.<ref>{{Cite web |title=Basic Tutorial — Cython 3.0a6 documentation |url=https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html |access-date=11 December 2020 |website=cython.readthedocs.io}}</ref>
The following code listings demonstrate the build and launch process.
 
Cython has a [[foreign function interface]] for invoking [[C (programming language)|C]]/[[C++]] [[subroutine|routines]] and the ability to declare the [[static type]] of subroutine parameters and results, local variables, and class attributes.
<source lang="Python">
# hello.pyx
def say_hello():
print "Hello World!"
</source>
 
A Cython program that implements the same algorithm as a corresponding Python program may consume fewer computing resources such as core memory and processing cycles due to differences between the CPython and Cython execution models. A basic Python program is loaded and executed by the CPython [[virtual machine]], so both the runtime and the program itself consume computing resources. A Cython program is compiled to C code, which is further compiled to machine code, so the virtual machine is used only briefly when the program is loaded.<ref>{{cite web |last=Oliphant |first=Travis |date=20 June 2011 |url=https://technicaldiscovery.blogspot.com/2011/06/speeding-up-python-numpy-cython-and.html |title=Technical Discovery: Speeding up Python (NumPy, Cython, and Weave) |publisher=Technicaldiscovery.blogspot.com |access-date=21 July 2013}}</ref><ref>{{cite journal |last1=Behnel |first1=Stefan |last2=Bradshaw |first2=Robert |last3=Citro |first3=Craig |last4=Dalcin |first4=Lisandro |last5=Seljebotn |first5=Dag Sverre |last6=Smith |first6=Kurt |year=2011 |title=Cython: The Best of Both Worlds |journal=Computing in Science and Engineering |volume=13 |issue=2 |pages=31–39 |doi=10.1109/MCSE.2010.118 |bibcode=2011CSE....13b..31B |s2cid=14292107 |url=https://research.google.com/pubs/pub36727.html|hdl=11336/13103 |hdl-access=free }}
<source lang="Python">
</ref><ref name="scipy09">{{cite book |last=Seljebot |first=Dag Sverre |title=Proceedings of the 8th Python in Science Conference |chapter=Fast numerical computations with Cython |year=2009 |pages=15–22 |doi=10.25080/GTCA8577 |chapter-url=http://conference.scipy.org/proceedings/SciPy2009/paper_2|doi-access=free }}</ref><ref>{{cite journal |last1=Wilbers |first1=I. |last2=Langtangen |first2=H. P. |last3=Ødegård |first3=Å. |year=2009 |title=Using Cython to Speed up Numerical Python Programs |journal=Proceedings of MekIT'09 |pages=495–512 |url=http://simula.no/research/sc/publications/Simula.SC.578/simula_pdf_file |access-date=14 June 2011 |format=PDF |editor1-first=B. |editor1-last=Skallerud |editor2-first=H. I. |editor2-last=Andersson |archive-date=4 January 2017 |archive-url=https://web.archive.org/web/20170104170007/http://simula.no/research/sc/publications/Simula.SC.578/simula_pdf_file |url-status=dead }}</ref>
# launch.py
import hello
hello.say_hello()
</source>
 
Cython employs:
<source lang="Python">
* Optimistic optimizations
# setup.py
* [[Type inference]] (optional)
from distutils.core import setup
* Low overhead in control structures
from distutils.extension import Extension
* Low function call overhead<ref>{{cite web |url=http://telecom.inescporto.pt/~gjc/pybindgen-benchmarks/ |title=wrapper benchmarks for several Python wrapper generators (except Cython) |access-date=28 May 2010 |archive-url=https://web.archive.org/web/20150404154630/http://telecom.inescporto.pt/~gjc/pybindgen-benchmarks/ |archive-date=4 April 2015 |url-status=dead}}</ref><ref>{{cite web |url=https://behnel.de/cycppbench/ |title=wrapper benchmarks for Cython, Boost.Python and PyBindGen |access-date=28 May 2010 |archive-url=https://web.archive.org/web/20160303224104/http://www.behnel.de/cycppbench/ |archive-date=3 March 2016 |url-status=dead}}</ref>
from Cython.Distutils import build_ext
 
Performance depends both on what C code is generated by Cython and how that code is compiled by the C compiler.<ref>{{cite web |title=Cython: C-Extensions for Python |url=http://cython.org/index.html |accessdate=22 November 2015}}</ref>
ext_modules = [Extension("hello", ["hello.pyx"])]
 
== History ==
setup(
Cython is a derivative of the [[Pyrex (programming language)|Pyrex language]], but it supports more features and optimizations than Pyrex.<ref>{{cite web |url=https://github.com/cython/cython/wiki/DifferencesFromPyrex |title=Differences between Cython and Pyrex|website=[[GitHub]] }}</ref><ref>{{cite web |last=Ewing |first=Greg |url=https://mail.python.org/pipermail/python-dev/2011-March/109642.html |title=Re: VM and Language summit info for those not at Pycon (and those that are!)|type=Message to the electronic mailing-list <code>python-dev</code> |date=21 March 2011 |access-date=5 May 2011}}</ref> Cython was [[Fork (software development)|forked]] from Pyrex in 2007 by developers of the [[SageMath|Sage]] computer algebra package, because they were unhappy with Pyrex's limitations and could not get patches accepted by Pyrex's maintainer Greg Ewing, who envisioned a much smaller scope for his tool than the Sage developers had in mind. They then forked Pyrex as SageX. When they found people were downloading Sage just to get SageX, and developers of other packages (including Stefan Behnel, who maintains the [[XML]] library {{proper name|LXML}}) were also maintaining forks of Pyrex, SageX was split off the Sage project and merged with <code>{{proper name|cython-lxml}}</code> to become Cython.<ref>{{cite web |author=Says Sage and Cython developer Robert Bradshaw at the Sage Days 29 conference |url=https://www.youtube.com/watch?v=osjSS2Rrvm0 |archive-url=https://ghostarchive.org/varchive/youtube/20211221/osjSS2Rrvm0 |archive-date=21 December 2021 |url-status=live |title=Cython: Past, Present and Future |via=[[YouTube]] |date=22 March 2011 |access-date=5 May 2011}}{{cbignore}}</ref>
name = 'Hello world app',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
</source>
 
Cython files have a <code>.pyx</code> extension. At its most basic, Cython code looks exactly like Python code. However, whereas standard Python is [[dynamic typing|dynamically typed]], in Cython, types can optionally be provided, allowing for improved performance, allowing loops to be converted into C loops where possible. For example:
These commands build and launch the program
<syntaxhighlight lang="cython">
# The argument will be converted to int or raise a TypeError.
def primes(int kmax):
 
# These variables are declared with C types.
<source lang="Bash">
cdef int n, k, i
$ python setup.py build_ext --inplace
$ python launch.py
</source>
 
# Another C type
== History ==
cdef int p[1000]
Cython is a derivative of the [[Pyrex (programming language)|Pyrex language]], and supports more features and optimizations than Pyrex.<ref>[http://wiki.cython.org/DifferencesFromPyrex Differences between Cython and Pyrex]</ref><ref>Greg Ewing, [http://mail.python.org/pipermail/python-dev/2011-March/109642.html Re: VM and Language summit info for those not at Pycon (and those that are!)]. Message to the electronic mailing-list <tt>python-dev</tt>, 21 March 2011. Retrieved 5 May 2011.</ref>
# A Python type
result = []
 
Cython was forked from Pyrex in 2007 by developers of the [[Sage (mathematics software)|Sage]] computer algebra package, because they were unhappy with Pyrex's limitations and could not get patches accepted by Pyrex's maintainer Greg Ewing, who envisioned a much smaller scope for his tool than the Sage developers had in mind. They then forked Pyrex as SageX. When they found people were downloading Sage just to get SageX, and developers of other packages (including Stefan Behnel, who maintains LXML) were also maintaining forks of Pyrex, SageX was split off the Sage project and merged with <tt>cython-lxml</tt> to become Cython.<ref>Says Sage and Cython developer Robert Bradshaw at the Sage Days 29 conference. [http://www.youtube.com/watch?v=osjSS2Rrvm0 Cython: Past, Present and Future], youtube.com, 22 March 2011. Retrieved 5 May 2011.</ref>
 
== Example ==
Cython files have a <code>.pyx</code> extension. At its most basic, Cython code looks exactly like Python code. However, whereas standard Python is [[dynamic typing|dynamically typed]], in Cython, types can optionally be provided, allowing for improved performance, allowing loops to be converted into C loops where possible. For example:
<source lang="Python">
def primes(int kmax): # The argument will be converted to int or raise a TypeError
cdef int n, k, i # These variables are declared with C types.
cdef int p[1000] # Another C type.
result = [] # A Python type.
if kmax > 1000:
kmax = 1000
 
k = 0
n = 2
 
while k < kmax:
i = 0
 
while i < k and n % p[i] != 0:
i = i + 1
 
if i == k:
p[k] = n
k = k + 1
result.append(n)
 
n = n + 1
 
return result
</syntaxhighlight>
</source>
 
== Example ==
== Static type declarations and Performance ==
[[File:Cython CPython Ext Module Workflow.png|thumb|Hello World in Cython]]
 
A sample [["Hello, World!" program|hello world]] program for Cython is more complex than in most languages because it interfaces with the Python C API and <code>setuptools</code> or other [[PEP517]]-compliant extension building facilities.{{technical inline|date=May 2024}} At least three files are required for a basic project:
A Cython program that implements the same algorithm as a corresponding Python program may consume fewer computing resources such as core memory and processing cycles due to differences between the CPython and Cython execution models. On the one hand, a basic Python program is loaded and executed by the CPython [[virtual machine]], so both the runtime and the program itself consume computing resources. On the other hand, a Cython program is compiled to C code, which is further compiled to machine code, so the virtual machine is used only briefly when the program is loaded.<ref>
http://technicaldiscovery.blogspot.com/2011/06/speeding-up-python-numpy-cython-and.html
</ref><ref>
{{cite journal |author= Stefan Behnel, Robert Bradshaw, Craig Citro, Lisandro Dalcin, Dag Sverre Seljebotn, Kurt Smith |year=2011 |title=Cython: The Best of Both Worlds |journal=Computing in Science and Engineering |volume=13 |issue=2 |pages=31–39 |doi=10.1109/MCSE.2010.118 |url=http://research.google.com/pubs/pub36727.html}}
</ref><ref name="scipy09">
{{cite journal |author=Dag Sverre Seljebot |year=2009 |title=Fast numerical computations with Cython |journal=Proceedings of the 8
th Python in Science Conference (SciPy 2009) |pages=15–22 |url= http://conference.scipy.org/proceedings/SciPy2009/paper_2}}
</ref><ref>
{{cite journal|author=I. Wilbers; H. P. Langtangen; Å. Ødegård | year=2009 | title=Using Cython to Speed up Numerical Python Programs | journal=Proceedings of MekIT'09 | pages=495–512 | url=http://simula.no/research/sc/publications/Simula.SC.578/simula_pdf_file | accessdate=June 14, 2011 | format=pdf | editor=B. Skallerud; H. I. Andersson}}</ref>
 
* A <code>setup.py</code> file to invoke the <code>setuptools</code> build process that generates the extension module
Cython employs
* A main python program to load the extension module
* Optimistic optimizations
* Cython source file(s)
* Type inference
* Low overhead in control structures
* Low function call overhead<ref>[http://telecom.inescporto.pt/~gjc/pybindgen-benchmarks/ wrapper benchmarks for several Python wrapper generators (except Cython)]</ref><ref>[http://behnel.de/cycppbench/ wrapper benchmarks for Cython, Boost.Python and PyBindGen]</ref>
 
The following code listings demonstrate the build and launch process:
Since C is the [[intermediate language]], performance will depend on the C compiler.
 
<syntaxhighlight lang="python">
# hello.pyx - Python module, this code will be translated to C by Cython.
def say_hello():
print("Hello World!")
</syntaxhighlight>
 
<syntaxhighlight lang="python">
# launch.py - Python stub loader, loads the module that was made by Cython.
 
# This code is always interpreted, like normal Python.
# It is not compiled to C.
 
import hello
hello.say_hello()
</syntaxhighlight>
 
<syntaxhighlight lang="python">
# setup.py - unnecessary if not redistributing the code, see below
from setuptools import setup
from Cython.Build import cythonize
 
setup(name = "Hello world app",
ext_modules = cythonize("*.pyx"))
</syntaxhighlight>
 
These commands build and launch the program:
 
<syntaxhighlight lang="bash">
$ python setup.py build_ext --inplace
$ python launch.py
</syntaxhighlight>
 
== Using in IPython/Jupyter notebook ==
A more straightforward way to start with Cython is through command-line [[IPython]] (or through in-browser python console called Jupyter [[notebook interface|notebook]]):
 
<syntaxhighlight lang="cython">
In [1]: %load_ext Cython
 
In [2]: %%cython
...: def f(n):
...: a = 0
...: for i in range(n):
...: a += i
...: return a
...:
...: cpdef g(int n):
...: cdef long a = 0
...: cdef int i
...: for i in range(n):
...: a += i
...: return a
...:
 
In [3]: %timeit f(1000000)
10 loops, best of 3: 26.5 ms per loop
 
In [4]: %timeit g(1000000)
1000 loops, best of 3: 279 µs per loop
</syntaxhighlight>
 
which gives a 95 times improvement over the pure-python version. More details on the subject in the official quickstart page.<ref>{{Cite web |url=https://cython.readthedocs.io/en/latest/src/quickstart/build.html |title=Building Cython code |website=cython.readthedocs.io |access-date=24 April 2017}}</ref>
 
== Uses ==
Cython is particularly popular among scientific users of Python,<ref name="scipy09" /><ref>{{cite web |title=inSCIght: The Scientific Computing Podcast, [|url=http://inscight.org/2011/03/31/episode_/ |type=Episode 6] |access-date=29 May 2011 |archive-url=https://web.archive.org/web/20141010032300/http://inscight.org/2011/03/31/episode_/ |archive-date=10 October 2014 |url-status=dead}}</ref><ref>{{cite journal |authorlast1=Jarrod Millman and Michael|first1=Jarrod |last2=Aivazis |first2=Michael |year=2011 |title=Python for Scientists and Engineers |journal=[[Computing in Science and Engineering]] |volume=13 |issue=2 |pages=9–12 |doi=10.1109/MCSE.2011.36 |bibcode=2011CSE....13b...9M |url=https://escholarship.org/uc/item/93s2v2s7}}</ref> where it has "the perfect audience" according to Python developercreator [[Guido van Rossum]].<ref>Who{{cite alsoweb criticizes|author=Guido Cython:Van [httpRossum |url=https://mail.python.org/pipermail/python-dev/2011-March/109634.html |title=Re: VM and Language summit info for those not at Pycon (and those that are!)]. |type=Message to the electronic mailing-list <ttcode>python-dev</ttcode>, |date=21 March 2011. Retrieved |access-date=5 May 2011.}}</ref> Of particular note:
 
* The [[free software]] [[SageMath]] computer algebra system depends on Cython, both for performance and to interface with other libraries.<ref>{{cite book |last1=Erocal |first1=Burcin |last2=Stein |first2=William |title=Mathematical Software – ICMS 2010 |chapter=The Sage Project: Unifying Free Mathematical Software to Create a Viable Alternative to Magma, Maple, Mathematica and MATLAB |year=2010 |volume=6327 |pages=12–27 |publisher=Springer Berlin / Heidelberg |doi=10.1007/978-3-642-15582-6_4 |url=http://wstein.org/papers/icms/icms_2010.pdf |series=Lecture Notes in Computer Science |isbn=978-3-642-15581-9 |citeseerx=10.1.1.172.624}}</ref>
* Significant parts of the scientific computing libraries [[SciPy]], [[Pandas (software)|pandas]] and [[scikit-learn]] are written in Cython.<ref>{{cite web |url=http://docs.scipy.org/doc/scipy/reference/release.0.7.2.html |title=SciPy 0.7.2 release notes |access-date=29 May 2011 |archive-date=4 March 2016 |archive-url=https://web.archive.org/web/20160304052117/http://docs.scipy.org/doc/scipy/reference/release.0.7.2.html |url-status=dead}}</ref><ref name="jmlr">{{cite journal |last1=Pedregosa |first1=Fabian |last2=Varoquaux |first2=Gaël |last3=Gramfort |first3=Alexandre |last4=Michel |first4=Vincent |last5=Thirion |first5=Bertrand |last6=Grisel |first6=Olivier |last7=Blondel |first7=Mathieu |last8=Prettenhofer |first8=Peter |last9=Weiss |first9=Ron |last10=Dubourg |first10=Vincent |last11=Vanderplas |first11=Jake |last12=Passos |first12=Alexandre |last13=Cournapeau |first13=David |title=Scikit-learn: Machine Learning in Python |journal=[[Journal of Machine Learning Research]] |year=2011 |volume=12 |pages=2825–2830 |arxiv=1201.0490|bibcode=2011JMLR...12.2825P }}</ref>
* Some high-traffic websites such as [[Quora]] use Cython.{{better source needed|date=October 2018}}<ref>{{cite web |url=https://www.quora.com/Is-Quora-still-running-on-PyPy/answer/Alex-Yakunin |title=Is Quora still running on PyPy?}}</ref>
 
Cython's ___domain is not limited to just numerical computing. For example, the {{proper name|lxml}} XML toolkit is written mostly in Cython, and like its predecessor Pyrex, Cython is used to provide Python bindings for many C and C++ libraries such as the messaging library [[ZeroMQ]].<ref>{{cite web |url=https://www.zeromq.org/bindings:python |title=ØMQ: Python binding}}</ref> Cython can also be used to develop [[parallel program]]s for [[multi-core processor]] machines; this feature makes use of the [[OpenMP]] library.
 
== See also ==
* The [[free software]] [[Sage (mathematics software)|Sage]] computer algebra system depends on Cython, both for performance and to interface with other libraries.<ref>{{cite journal |author=Burcin Erocal and William Stein |year=2010 |title=The Sage Project: Unifying Free Mathematical Software to Create a Viable Alternative to Magma, Maple, Mathematica and MATLAB |journal=Mathematical Software‚ ICMS 2010 |volume=6327 |pages=12–27 |publisher=Springer Berlin / Heidelberg |doi=10.1007/978-3-642-15582-6_4 |url=http://wstein.org/papers/icms/icms_2010.pdf}}</ref>
* [[PyPy]]
* Significant parts of the scientific and numerical computing libraries [[SciPy]] and [[NumPy]] are written in Cython.<ref>[http://docs.scipy.org/doc/scipy/reference/release.0.7.2.html SciPy 0.7.2 release notes]</ref><ref>[http://projects.scipy.org/numpy/ticket/727 NumPy ticket] talking about moving from Pyrex to Cython</ref>
* [[Numba]]
* [[pybind]]
 
== References ==
Cython's ___domain is not limited to just numerical computing. For example, the [http://codespeak.net/lxml lxml] XML toolkit is written mostly in Cython, and Cython is used to provide Pythonic bindings for many C and C++ libraries ranging from the graphics library [[OpenGL]]<ref>[http://pyopengl.sourceforge.net/ PyOpenGL: The Python OpenGL Binding]</ref> to the messaging library [[ZeroMQ]].<ref>[http://www.zeromq.org/bindings:python http://www.zeromq.org/bindings:python]</ref>
{{reflist|30em}}
 
== External links ==
==References==
* {{Official website}}
{{Reflist|2}}
* {{GitHub|cython}}
 
{{Python (programming language)}}
==External links==
* {{official website|http://cython.org}}
 
[[Category:Articles with example Python (programming language) code]]
[[Category:Python (programming language)]]
[[Category:Python (programming language) implementations]]
[[Category:Software using the Apache license]]
[[Category:Source-to-source compilers]]