Python interpreter speed

Stefan Behnel stefan_ml at behnel.de
Tue Apr 21 02:46:19 EDT 2009


Tim Roberts wrote:
> The Python you're thinking of (CPython) is compiled to an intermediate
> language, which is then interpreted by an interpreter loop, somewhat
> remeniscent of Forth.  It takes more cycles per instruction to run that
> interpreter loop than it does to run the machine language, but not by much.
> Java is not that much faster than CPython.
> 
> There is another implementation (Jython) which compiled Python to the Java
> intermediate language, which can then be JIT compiled, exactly like Java.
> 
> There is also IronPython, which is Python for the .NET framework.  It
> compiles to a different intermediate language, which is also compiled at
> execution time to machine code.

Not to forget PyPy, which uses an optimising JIT to compile things to
native code.

There's also Cython, where the intermediate language is (optimised) C, and
the compilation to machine code happens at build time (or JIT-like at
import time if you use pyximport).

Regarding this:

> Java is not that much faster than CPython.

That is a rather simplified statement. To be a tiny bit more accurate, Java
is faster for some applications and slower for others.

Stefan



More information about the Python-list mailing list