Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.6k
The most widely used Python to C compiler
License
Apache-2.0, Unknown licenses found
Licenses found
cython/cython
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Cython is an optimising Python compiler that makes writing C extensions forPython as easy as Python itself.
Cython translates Python code to C/C++ code, but additionally supports callingC functions and declaring C types on variables and class attributes.This allows broad to fine-grained manual tuning that lets the compilergenerate very efficient C code from Cython code.
This makes Cython the ideal language for wrapping external C libraries, andfor fast C modules that speed up the execution of Python code.
- Official website:https://cython.org/
- Documentation:https://docs.cython.org/
- Github repository:https://github.com/cython/cython
- Wiki:https://github.com/cython/cython/wiki
Cython hasmore than 70 million downloadsper month on PyPI. You cansupport the Cython project viaGithub Sponsors orTidelift.
If you already have a C compiler, just run following command:
pip install Cython
otherwise, seethe installation page.
The original Pyrex program, which Cython is based on, was licensed "free of restrictions" (see below).Cython itself is licensed under the permissiveApache License.
SeeLICENSE.txt.
Want to contribute to the Cython project?Here is somehelp to get you started.
Started as a project in the early 2000s, Cython has outlivedmost other attemptsat producing static compilers for the Python language.
Similar projects that have a relevance today include:
- PyPy, a Python implementation with a JIT compiler.
- Pros: JIT compilation with runtime optimisations, fully language compliant,good integration with external C/C++ code
- Cons: non-CPython runtime, relatively large resource usage of the runtime,limited compatibility with CPython extensions, non-obvious performance results
- Numba, a Python extension that features aJIT compiler for a subset of the language, based on the LLVM compilerinfrastructure (probably best known for its
clang
C compiler).It mostly targets numerical code that uses NumPy.- Pros: JIT compilation with runtime optimisations
- Cons: limited language support, relatively large runtime dependency (LLVM),non-obvious performance results
- Pythran, a static Python-to-C++extension compiler for a subset of the language, mostly targetedat numerical computation. Pythran can be (and is probably best) usedas an additionalbackend for NumPy codein Cython.
- mypyc, a static Python-to-C extensioncompiler, based on themypy static Pythonanalyser. Like Cython'spure Python mode,mypyc can make use of PEP-484 type annotations to optimise code for static types.
- Pros: good support for language and PEP-484 typing, good type inference,reasonable performance gains
- Cons: no support for low-level optimisations and typing,opinionated Python type interpretation, reduced Python compatibilityand introspection after compilation
- Nuitka, a static Python-to-C extension compiler.
- Pros: highly language compliant, reasonable performance gains,support for static application linking (similar tocython_freezebut with the ability to bundle library dependencies into a self-containedexecutable)
- Cons: no support for low-level optimisations and typing
In comparison to the above, Cython provides
- fast, efficient and highly compliant support for almost allPython language features, including dynamic features and introspection
- full runtime compatibility with all still-in-use and future versionsof CPython
- "generate once, compile everywhere" C code generation that allows forreproducible performance results and testing
- C compile time adaptation to the target platform and Python version
- support for other C-API implementations, including PyPy and Pyston
- seamless integration with C/C++ code
- broad support for manual optimisation and tuning down to the C level
- a large user base with thousands of libraries, packages and tools
- more than two decades of bug fixing and static code optimisations
Cython was originally based onPyrexby Greg Ewing, with the following written in the Pyrex readme document:
This is a development version of Pyrex, a languagefor writing Python extension modules.
For more info, take a look at:
- Doc/About.html for a description of the language
- INSTALL.txt for installation instructions
- USAGE.txt for usage instructions
- Demos for usage examples
Comments, suggestions, bug reports, etc. are mostwelcome!
Copyright stuff: Pyrex is free of restrictions. Youmay use, redistribute, modify and distribute modifiedversions.
The latest version of Pyrex can be foundhere.
A citizen of NewZealandCorp, a wholly-owned subsidiary of USA Inc.
About
The most widely used Python to C compiler
Topics
Resources
License
Apache-2.0, Unknown licenses found
Licenses found
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.