cpython/Tools/jit
alm d3d94e0ed7
Some checks failed
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run
JIT / Interpreter (Debug) (push) Has been cancelled
JIT / aarch64-pc-windows-msvc/msvc (Release) (push) Has been cancelled
JIT / aarch64-pc-windows-msvc/msvc (Debug) (push) Has been cancelled
JIT / i686-pc-windows-msvc/msvc (Release) (push) Has been cancelled
JIT / i686-pc-windows-msvc/msvc (Debug) (push) Has been cancelled
JIT / aarch64-apple-darwin/clang (Release) (push) Has been cancelled
JIT / aarch64-unknown-linux-gnu/gcc (Release) (push) Has been cancelled
JIT / aarch64-apple-darwin/clang (Debug) (push) Has been cancelled
JIT / aarch64-unknown-linux-gnu/gcc (Debug) (push) Has been cancelled
JIT / x86_64-pc-windows-msvc/msvc (Release) (push) Has been cancelled
JIT / x86_64-pc-windows-msvc/msvc (Debug) (push) Has been cancelled
JIT / x86_64-apple-darwin/clang (Release) (push) Has been cancelled
JIT / x86_64-unknown-linux-gnu/gcc (Release) (push) Has been cancelled
JIT / x86_64-apple-darwin/clang (Debug) (push) Has been cancelled
JIT / x86_64-unknown-linux-gnu/gcc (Debug) (push) Has been cancelled
gh-138061: Exclude __pycache__ directory from the computed digest in the JIT stencils (#138131)
Exclude the __pycache__ directory when generating the digest in the JIT stencils
2025-08-30 22:21:25 +01:00
..
_llvm.py GH-113464: Get LLVM from cpython-bin-deps on Windows (GH-133278) 2025-05-02 11:17:15 -07:00
_optimizers.py GH-135904: Improve the JIT's performance on macOS (GH-136528) 2025-07-14 10:14:20 -07:00
_schema.py
_stencils.py GH-135904: Optimize the JIT's assembly control flow (GH-135905) 2025-06-27 08:20:51 -07:00
_targets.py gh-138061: Exclude __pycache__ directory from the computed digest in the JIT stencils (#138131) 2025-08-30 22:21:25 +01:00
_writer.py GH-137959: Replace shim code in jitted code with a single trampoline function. (GH-137961) 2025-08-21 10:40:53 +01:00
build.py GH-134273: Allow setting JIT compiler flags at build time with CFLAGS_JIT (GH134276) 2025-06-12 16:11:08 -07:00
jit.h GH-135904: Improve the JIT's performance on macOS (GH-136528) 2025-07-14 10:14:20 -07:00
mypy.ini
README.md GH-113464: Add the JIT to What's New (GH-133486) 2025-05-05 20:06:41 -07:00
template.c GH-137959: Replace shim code in jitted code with a single trampoline function. (GH-137961) 2025-08-21 10:40:53 +01:00
trampoline.c GH-137959: Replace shim code in jitted code with a single trampoline function. (GH-137961) 2025-08-21 10:40:53 +01:00

The JIT Compiler

This version of CPython can be built with an experimental just-in-time compiler1. While most everything you already know about building and using CPython is unchanged, you will probably need to install a compatible version of LLVM first.

Python 3.11 or newer is required to build the JIT.

Installing LLVM

The JIT compiler does not require end users to install any third-party dependencies, but part of it must be built using LLVM2. You are not required to build the rest of CPython using LLVM, or even the same version of LLVM (in fact, this is uncommon).

LLVM version 19 is required. Both clang and llvm-readobj need to be installed and discoverable (version suffixes, like clang-19, are okay). It's highly recommended that you also have llvm-objdump available, since this allows the build script to dump human-readable assembly for the generated code.

It's easy to install all of the required tools:

Linux

Install LLVM 19 on Ubuntu/Debian:

wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19

Install LLVM 19 on Fedora Linux 40 or newer:

sudo dnf install 'clang(major) = 19' 'llvm(major) = 19'

macOS

Install LLVM 19 with Homebrew:

brew install llvm@19

Homebrew won't add any of the tools to your $PATH. That's okay; the build script knows how to find them.

Windows

LLVM is downloaded automatically (along with other external binary dependencies) by PCbuild\build.bat.

Otherwise, you can install LLVM 19 by searching for it on LLVM's GitHub releases page, clicking on "Assets", downloading the appropriate Windows installer for your platform (likely the file ending with -win64.exe), and running it. When installing, be sure to select the option labeled "Add LLVM to the system PATH".

Alternatively, you can use chocolatey:

choco install llvm --version=19.1.0

Building

For PCbuild-based builds, pass the --experimental-jit option to build.bat.

For all other builds, pass the --enable-experimental-jit option to configure.

Otherwise, just configure and build as you normally would. Cross-compiling "just works", since the JIT is built for the host platform.

The JIT can also be enabled or disabled using the PYTHON_JIT environment variable, even on builds where it is enabled or disabled by default. More details about configuring CPython with the JIT and optional values for --enable-experimental-jit can be found here.


  1. PEP 744 ↩︎

  2. Clang is specifically needed because it's the only C compiler with support for guaranteed tail calls (musttail), which are required by CPython's continuation-passing-style approach to JIT compilation. Since LLVM also includes other functionalities we need (namely, object file parsing and disassembly), it's convenient to only support one toolchain at this time. ↩︎