Despite 30 months work, core developer says Python’s JIT compiler is often slower than the interpreter

Despite 30 months work, core developer says Python’s JIT compiler is often slower than the interpreter

Ken Jin, a CPython core developer who works on the experimental JIT (just in time) compiler optimizer, says that after two and half years work, the “JIT ranges from slower than the interpreter to roughly equivalent to the interpreter.”

The JIT compiler is included in Python 3.13, released in October 2024, but only when CPython is built using the –enable-experimental-jit option. Early reports spoke of a speed-up of between 2 and 9 percent; but Jin said that “it’s really more nuanced than that. Often times, the CPython 3.13 JIT is a lot slower than the interpreter.”

Part of the confusion, Jin said, is because Python 3.13 has more than one interpreter. The docs explain that at runtime the python interpreter “starts with specialized Tier 1 bytecode” but when it sees repeated use of the same code, “it gets translated to a new purely internal intermediate representation (IR) called the Tier 2 IR.” This Tier 2 IR is better suited to JIT compilation to machine code. However there is also a Tier 2 interpeter which is “mostly intended for debugging the earlier stages of the optimization pipeline.” Some performance comparisons are between the JIT-compiled code and the Tier 2 interpreter, which is misleading as “it’s not comparing to the actual CPython interpreter.”

Another complication is that the performance of CPython varies according to the compiler used to build it. When it is built using a modern compiler like Clang 20, Jin said, the interpreter often out-performs the JIT. If an old compiler like GCC 11 is used though, the JIT may be equal or faster than the interpreter.

Python 3.14 is in development, with release scheduled for October 2025. Will JIT performance improve? In some cases, Jin said, but overall “the 3.14 JIT has almost no major optimizer features over 3.13.” There are improvements to the code generator, he said.

One reason for the slow progress of the JIT is that the work on it is done by a small, community-driven team, led by Mark Shannon. Microsoft cancelled its support for the Faster CPython project in May this year, as part of a round of layoffs; but this did not impact the work on the JIT, Jin said, as this was always a community project. At times, only one person was working on it, Brandt Bucher who co-wrote PEP 744, the Python Enhancement Proposal regarding the JIT compiler. Increasing the size of the team has been a focus, and Jin names three additional contributors.

Jin is hopeful that there could be “single-digit percentage speedups to the JIT” in Python 3.15, the major version after the next release.

Python is the second most popular language after JavaScript according to rankings such as this, but the standard implementation, CPython, is slow compared to most other languages, not only native compiled languages such as C++ or Go, but also versus interpreted languages like Java and JavaScript.

The JIT compiler is part of an effort to speed up Python, but not the only one. The Faster CPython project has introduced other optimizations which have been effective. The option to disable the GIL (Global Interpreter Lock), which is in 3.13, enables better performance by running threads in parallel. 

CPython is getting faster; but in most cases it is not yet because of the newly available JIT. Although disappointing, we note that Shannon told sister publication The Register in 2021 that a JIT compiler was not a “magic cure-all” and that prioritising optimisation of the interpreter makes sense. “if you do it in the interpreter then it is already done for the compiler, and the interpreter gets faster, so it makes sense to do it first,” he said.