Python announced a new update yesterday that added support to the JIT (Just in Time) compiler. This addition, made by CPython core developer Brandt Bucher in the end of 2023, is a substantial change to the CPython Interpreter.
The inclusion of the JIT compiler in Python 3.13 builds upon the earlier introduction of the Specialising Adaptive Interpreter in Python 3.11, continuing the trend of significant updates to boost Python’s performance. This update is building on the progress made with the adaptive interpreter in Python 3.11.
The JIT compiler changes the Python code into machine code when the code is run for the first time, unlike Ahead of Time (AOT) compilers like GCC or Rust’s rustc. This new compiler type copies instructions for each command and fills in the blanks for bytecode arguments.
The copy-and-patch JIT was chosen for its simplicity and efficiency compared to a full JIT compiler. It avoids the complexity and resource demands of compiling high-level bytecodes into an Intermediate Language (IL) and then into machine code. This approach is particularly beneficial for Python, which runs on various CPU architectures.
The initial benchmarks show a performance improvement of 2-9%. While this might seem modest, it lays the groundwork for more significant optimisations in the future. This update is not just about immediate performance gains but also about setting a foundation for future advancements in Python’s efficiency.