DEVOURED
What's new in Python 3.15
Python 3.15 introduces significant performance boosts via a revamped JIT compiler and explicit lazy imports, alongside new built-in types like `frozendict` and `sentinel`, and enhanced developer diagnostics.
What: Python 3.15, released June 2026, ships with major features including PEP 810 for explicit lazy imports with a new `lazy` keyword to speed up startup times, PEP 814 adding a built-in immutable `frozendict` type, and PEP 661 introducing a `sentinel` type. The JIT compiler sees an 8-9% geometric mean performance improvement on x86-64 Linux and 12-13% on AArch64 macOS, supporting more bytecode operations and improving machine code generation. Error messages are also improved with suggestions and color.
Why it matters: This release shows Python's commitment to addressing long-standing performance bottlenecks like startup time and execution speed, while also refining language features and developer experience, making it more competitive for large-scale and high-performance applications.
Takeaway: Developers should consider using the new `lazy` keyword for imports in large Python applications to potentially improve startup times. Explore `frozendict` for immutable dictionary needs and be aware of the performance gains from the upgraded JIT, especially for compute-intensive tasks.
Deep dive
- PEP 810: Explicit lazy imports: Introduces a
lazysoft keyword forimportstatements, deferring module loading until the imported name is first used. This reduces application startup times, especially for deep dependency trees, without requiring code restructuring.* PEP 814: Addfrozendictbuilt-in type: A new immutable, hashable dictionary type that preserves insertion order but is not a subclass ofdict. It's useful for scenarios requiring immutable mappings, e.g., as dictionary keys.* PEP 661: Addsentinelbuilt-in type: A new type for creating unique sentinel values, useful in APIs whereNoneor other common values could be ambiguous.* Upgraded JIT compiler: Delivers 8-9% geometric mean performance improvement on x86-64 Linux and 12-13% on AArch64 macOS. Major upgrades include an LLVM 21 build-time dependency, a new tracing frontend supporting more bytecode operations, basic register allocation, and additional optimizations.* PEP 799: Dedicated profiling package: A newprofilingmodule replacescProfileandprofile(deprecated). It includesprofiling.tracing(deterministic) and the newTachyonstatistical sampling profiler.* Tachyon: High frequency statistical sampling profiler: Added asprofiling.sampling, offering zero-overhead performance analysis for running Python processes with sampling rates up to 1,000,000 Hz. Supports wall-clock, CPU, GIL-holding, and exception handling time modes, with output to pstats, collapsed stacks for flame graphs, interactive flame graphs, and live TUI mode.* PEP 831: Frame pointers enabled by default: CPython now builds with frame pointers by default on supported platforms, making native stack unwinding faster and more reliable for debuggers and profilers.* PEP 798: Unpacking in comprehensions: List, set, and dictionary comprehensions, and generator expressions now support*and**unpacking, simplifying code for combining iterables or dictionaries.* PEP 686: UTF-8 as default encoding: Python now uses UTF-8 as the default encoding for I/O operations without an explicit encoding argument, independent of the system environment.* Improved error messages: Interpreter provides more helpful suggestions inAttributeErrorexceptions, including nested attribute suggestions (e.g.,.inner.area), Python equivalents for common methods from other languages (e.g.,.appendfor.push), and suggestions for mutable counterparts when calling mutable methods on immutable types.* Newbytearray.take_bytes()method: Allows taking bytes out of abytearraywithout copying, optimizing common patterns for returning, emptying, or splitting buffers.* Stable ABI for free-threaded builds (abi3t): C extensions targeting the Stable ABI can now be compiled for free-threaded builds, requiring specific C API changes.* Security enhancements:tarfilemodule improved against path traversal attacks and other vulnerabilities.
Decoder
- JIT (Just-In-Time) Compiler: A compiler that translates bytecode into machine code during program execution, rather than before, aiming to improve performance by optimizing frequently run code.* Lazy import: A programming technique where a module is not loaded into memory until it is actually needed, rather than at the program's start, to reduce startup time and memory footprint.* Frozendict: An immutable version of Python's dictionary, meaning its contents cannot be changed after creation. It can be used as a key in another dictionary or as an element in a set because it is hashable.* Sentinel value: A special value used to indicate the end of a data set or to represent a unique state, distinct from any valid data values.* Frame pointers: A register or memory location that points to the base of the current stack frame, used by debuggers and profilers to reconstruct call stacks.* Comprehension: A concise way to create lists, dictionaries, or sets in Python (e.g., list comprehension
[expr for item in iterable]).* UTF-8: A variable-width character encoding for Unicode, which is capable of encoding all 1,112,064 valid character code points in Unicode.* Stable ABI (Application Binary Interface): A set of conventions for how different parts of a program (or different programs) interact at a binary level, ensuring compatibility across different versions or builds without needing recompilation.* Tachyon: A high-frequency statistical sampling profiler introduced in Python 3.15, designed for low-overhead performance analysis of running Python processes by periodically capturing stack traces.* Multithreading (Free-threaded builds): A build of Python that aims to improve concurrency by allowing multiple native threads to execute Python bytecode in parallel, potentially removing or relaxing the Global Interpreter Lock (GIL).
Original article
Full article content is not available for inline reading.
Explore all 55 articles in today's digest
Fresh dev news, AI-digested daily. Never miss a trend at devoured.fyi