I've been using CPython for my Python projects, but I've heard that there are alternative compilers for Python as well. What are these alternative compilers, and what benefits do they offer compared to CPython?
Asked
Active
Viewed 66 times
2
-
https://www.python.org/download/alternatives/ – Brian61354270 Aug 04 '23 at 11:54
-
CPython is not a compiler but an *interpreter* (not even with a JIT compiler). Pypy and Pyston both have a JIT compiler integrated though a part is still interpreted. – Jérôme Richard Aug 04 '23 at 12:06
-
Re: @Jérôme comments, see also [Is Python interpreted, or compiled, or both?](https://stackoverflow.com/q/6889747/). Whether or not CPython is compiled is a largely matter of perspective/definitions. Some say CPython is compiled, since CPython uses the same execution model as Java (bytecode compiler, then executed on a virtual machine). Some disagree with that label, since, as a design choice, CPython's compiler is very lean so that Python code can be compiled and run on the fly without substantial build delays. That makes it behave more like a tradition interpreted implementation. – Brian61354270 Aug 04 '23 at 12:28
-
There days, virtually no _purely_ interpreted languages exists (as from shell languages). When people say that an implementation is interpreted, they often means "compiled really fast", which usually comes minimal attempts at optimization. – Brian61354270 Aug 04 '23 at 12:32
-
@Brian61354270 I disagree with the part of the answer saying that "Python is compiled". The bytecode is indeed compilation (and it can be seen as an internal caching step), but it is then interpreted (as opposed to most Java/C# implementation which use JIT compilers). I am not the only one to disagree with this point : the top up-voted comment of the answer mention this. For a better answer, the best is to [read the Python documentation](https://docs.python.org/3/faq/general.html) : *"Python is an interpreted, interactive, object-oriented programming language"* (they should have said CPython) – Jérôme Richard Aug 04 '23 at 14:57
-
@Brian61354270 Regarding Java, the distinction is not so clear so it is fine. There are full Java to native-code compilers (without any VM), so Java can be fully compiled (not even with a JIT compiler), although the default implementation is a mix of multiple JIT compilers, a bytecode compiler (and it was partially interpreted previously). We can say that Java code is generally compiled to bytecode and executed in a *JVM*. Regarding C#, Microsoft says that the language is *managed* (similar to Java in practice). AOT compilers also exist for C#. – Jérôme Richard Aug 04 '23 at 15:09
-
@Brian61354270 Note that *Cython* (not to be confused with CPython) can fully statically compile Python codes to native codes (though whether this is still Python codes is arguable since it requires annotations in a superset of Python to do that). – Jérôme Richard Aug 04 '23 at 15:17
1 Answers
2
Python.org maintains a list of popular alternative implementations. You can access it by navigating to "Downloads" > "Alternative Implementation" from the homepage, or visit https://www.python.org/download/alternatives/.
This site hosts the "traditional" implementation of Python (nicknamed CPython). A number of alternative implementations are available as well, namely
- IronPython (Python running on .NET)
- Jython (Python running on the Java Virtual Machine)
- PyPy (A fast python implementation with a JIT compiler)
- Stackless Python (Branch of CPython supporting microthreads)
- MicroPython (Python running on micro controllers)
Do note that alternative implementations typically lag behind CPython in version compatibility and feature support. As of this posting (August 3 2023), these alternative implementations advertise having support up to the below listed Python versions:
- CPython (flagship): 3.11
- IronPython: 3.4
"The latest stable version of IronPython 3 is IronPython 3.4.1, which is compatible with Python 3.4." - Jython: 2.7
"The current release (a Jython 2.7.x) only supports Python 2 (sorry)." - PyPy: 3.10
"We currently support python 3.10, 3.9, and 2.7." - Stackless Python: 3.8
"The documentation: 3.8, 3.7.9 and 3.6.13" - MicroPython: 3.4
"MicroPython aims to implement the Python 3.4 standard (with selected features from later versions)"

Brian61354270
- 8,690
- 4
- 21
- 43