Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The most widely used Python to C compiler

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE.txt
Unknown
COPYING.txt
NotificationsYou must be signed in to change notification settings

cython/cython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Cython hasmore than 70 million downloadsper month on PyPI. You cansupport the Cython project viaGithub Sponsors orTidelift.

Installation:

If you already have a C compiler, just run following command:

pip install Cython

otherwise, seethe installation page.

License:

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.

Contributing:

Want to contribute to the Cython project?Here is somehelp to get you started.

Differences to other Python compilers

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 itsclang 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

The following is from Pyrex:

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.

Greg Ewing, Computer Science Dept
University of Canterbury
Christchurch, New Zealand
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

Apache-2.0
LICENSE.txt
Unknown
COPYING.txt

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp