Cython
mypyc
Cython | mypyc | |
---|---|---|
80 | 28 | |
9,715 | 1,776 | |
1.7% | 1.6% | |
9.7 | 0.0 | |
2 days ago | almost 2 years ago | |
Python | ||
Apache License 2.0 | - |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Cython
- I Use Nim Instead of Python for Data Processing
- Ask HN: C/C++ developer wanting to learn efficient Python
- Ask HN: Is there a way to use Python statically typed or with any type-checking?
- Cython 3.0
-
How to make a c++ python extension?
The approach that I favour is to use Cython. The nice thing with this approach is that your code is still written as (almost) Python, but so long as you define all required types correctly it will automatically create the C extension for you. Early versions of Cython required using Cython specific typing (Python didn't have type hints when Cython was created), but it can now use Python's type hints.
-
Never again
and again, everything that was released after using an older version of cython.
-
Codon: Python Compiler
Just for reference,
* Nuitka[0] "is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, and 3.11."
* Pypy[1] "is a replacement for CPython" with builtin optimizations such as on the fly JIT compiles.
* Cython[2] "is an optimising static compiler for both the Python programming language and the extended Cython programming language... makes writing C extensions for Python as easy as Python itself."
* Numba[3] "is an open source JIT compiler that translates a subset of Python and NumPy code into fast machine code."
* Pyston[4] "is a performance-optimizing JIT for Python, and is drop-in compatible with ... CPython 3.8.12"
[0] https://github.com/Nuitka/Nuitka
[1] https://www.pypy.org/
[2] https://cython.org/
[3] https://numba.pydata.org/
[4] https://github.com/pyston/pyston
- Slow Rust Compiler is a Feature, not a Bug.
-
Any faster Python alternatives?
Profile and optimize the hotspots with cython (or whatever the cool kids are using these days... It's been a while.)
-
What exactly is 'JIT'?
JIT essentially means generating machine code for the language on the fly, either during loading of the interpreter (method JIT), or by profiling and optimizing hotspots (tracing JIT). The language itself can be statically or dynamically typed. You could also compile a dynamic language ahead of time, for example, cython.
mypyc
- Advanced Python: Achieving High Performance with Code Generation
-
Free-threaded CPython is ready to experiment with
s/will never be/already is/g
https://github.com/mypyc/mypyc
You can compile python to c. Right now. Compatibility with extensions still needs a bit of work. But you can write extremely strict python.
That's without getting into things like cython.
- Making use of type hints
-
Writing Python like it's Rust
That would be interesting! You might already be aware. But there's mypyc[0], which is an AOT compiler for Python code with type hints (that, IIRC, mypy uses to compile itself into a native extension).
Wanted to give you a head-start on the lit-review for your students I guess :)
[0] https://github.com/mypyc/mypyc
-
The different uses of Python type hints
https://github.com/mypyc/mypyc
> Mypyc compiles Python modules to C extensions. It uses standard Python type hints to generate fast code. Mypyc uses mypy to perform type checking and type inference.
> Mypyc can compile anything from one module to an entire codebase. The mypy project has been using mypyc to compile mypy since 2019, giving it a 4x performance boost over regular Python.
I have not experience a 4x boost, rather between 1.5x and 2x. I guess it depends on the code.
-
The Python Paradox
Funny how emergence works with tools. Give a language too few tools but viral circumstances - the ecosystem diverges (Lisps, Javascript). Give it too long an iteration time but killer guarantees, you end up with committees. Python not falling into either of these traps should be understood as nothing short of magic in emergence.
I only recently discovered that python's reference typechecker, mypy, has a small side project for typed python to emit C [1], written entirely in python. Nowadays with python's rich specializer ecosystem (LLVM, CUDA, and just generally vectorized math), the value of writing a small program in anything else diminishes quickly.
Imagine reading the C++wg release notes in the same mood that you would the python release notes.
[1] https://github.com/mypyc/mypyc
-
Codon: A high-performance Python compiler
> Note that the mypyc issue tracker lives in this repository! Please don't file mypyc issues in the mypy issue tracker.
See https://github.com/mypyc/mypyc/blob/master/show_me_the_code....
-
ELI5: Can’t one write a compiler for Python and make everything go brrrr?
And mypyc https://github.com/mypyc/mypyc
-
Is it time for Python to have a statically-typed, compiled, fast superset?
More recent approaches include mypyc which is (on the tin) quite close to what you describe, and taichi that lives in between.
-
Pholyglot version 0.0.0 (PHP to PHP+C polyglot transpiler)
Have you encountered mypyc?
What are some alternatives?
SWIG - SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.
beartype - Unbearably fast near-real-time hybrid runtime-static type-checking in pure Python.
Pyston - (No longer maintained) A faster and highly-compatible implementation of the Python programming language.
mypy - Optional static typing for Python
PyPy
pyccel - Python extension language using accelerators
Pyjion
benchmarks - Some benchmarks of different languages
dramatiq - A fast and reliable background task processing library for Python 3.
gomacro - Interactive Go interpreter and debugger with REPL, Eval, generics and Lisp-like macros
ctypes.sh - A foreign function interface for bash.
pex - A tool for generating .pex (Python EXecutable) files, lock files and venvs.