The JIT Compiler in Python 3.14

Python 3.14 includes an experimental JIT compiler in official binaries. Based on the copy-and-patch technique, it compiles the most-executed bytecodes into native machine code on the fly, without requiring LLVM at runtime.

How to Enable It

The JIT is disabled by default. Enable it with the PYTHON_JIT=1 environment variable or the -X jit flag.

python
# Enabling the JIT
# $ PYTHON_JIT=1 python my_script.py
# or
# $ python -X jit my_script.py

import sys

# Check if JIT is available in this build
jit_available = hasattr(sys, '_jit')
print(f"JIT available: {jit_available}")

# The JIT targets hot loops and frequently
# called functions. It is transparent:
# no source code changes needed.

What Code Benefits?

The JIT mainly accelerates tight loops and pure Python numerical code. Typical gains are 5-15% on general benchmarks, more on intensive computation. It does not replace PyPy for massive gains, but it works with the full C extension ecosystem (NumPy, etc.).

python
import time


def fibonacci(n: int) -> int:
    """Iterative Fibonacci computation."""
    a, b = 0, 1
    for _ in range(n):
        a, b = b, a + b
    return a


def benchmark():
    start = time.perf_counter()
    for _ in range(1000):
        fibonacci(10_000)
    elapsed = time.perf_counter() - start
    return elapsed


# Typical results on Python 3.14:
t = benchmark()
print(f"Duration: {t:.3f}s")
# Without JIT: ~2.1s
# With JIT:    ~1.8s (~15% faster)
# PyPy:        ~0.3s (PyPy still faster for pure Python)

# CPython JIT advantage: full compatibility
# with C extensions (NumPy, Pandas, etc.)

Sources