DevOps
JIT compiler much improved, but no reinstatement for leaky incremental garbage collector
The Python team has released the first beta of version 3.15,
with new features including a stable application binary interface (ABI) for free-threaded
CPython, lazy imports to speed startup time, a new zero-overhead sampling
profiler, use of UTF-8 text encoding by default, and a faster just-in-time (JIT) compiler.
Python’s development cycle bars new features after the first beta release. There is typically a new feature release in October
each year, with version 3.15 currently scheduled for October 1.
The option to remove the global interpreter lock (GIL), available
in Python 3.14, was the biggest change to Python for years, enabling efficient
concurrency on multi-core CPUs. The new stable ABI means that C extensions can
now be compiled for multiple minor versions of free-threaded builds, though the
team warns that doing so means only a
subset of the full CPython API is available. The existing stable ABI remains available,
and it is possible to compile for both. Extension maintainers will benefit,
since building new versions for every minor Python release is a burden.Â
Explicit lazy imports can improve startup time for Python
applications by deferring module loading until it is first accessed. Otherwise, an
imported module is loaded and compiled to bytecode immediately – though developers
could use workarounds at the expense of code readability. The solution for this
is a new keyword:Â
lazy import json
A new sampling profiler called Tachyon works by capturing
stack traces from running processes, instead of instrumenting function calls.
According to the docs, the approach “provides virtually zero
overhead while achieving sampling rates of up to 1,000,000 Hz” and can be
used to debug performance issues in production.
Text encoding in Python 3.15 is now UTF-8 by default, though
explicit encoding is still recommended for best compatibility.
CPython is the reference implementation of Python, and improving its performance has long been a focus. An experimental JIT compiler was introduced in version
3.14, though not recommended for production use – and could make code run more
slowly.
In 3.15, the JIT compiler is much improved, and the team now reports an 8-9
percent mean performance improvement over the CPython interpreter on x86-64
Linux, and 12-13 percent on Apple silicon macOS, though some code may still run
up to 15 percent slower. These figures may change before the final release.
In contrast, the incremental garbage collector released in
3.14 has been reverted, following reports of memory leaks. This aimed to improve performance by reclaiming memory less frequently. It was removed in Python 3.14.5 and the core team stated:Â
“If we want to reintroduce the incremental GC
for 3.16, it can go through the regular PEP process and be more thoroughly
evaluated.”
The full list of what is new in 3.15 is documented here.®