Python 3.15 Updates: Lazy Imports, Tachyon Profiling, and Version Support Shifts
This article outlines key updates in Python 3.15, including explicit lazy imports, collection unpacking in comprehensions, a built-in sampling profiler, and the end-of-life status for Python 3.10.
According to Simon Willison's Python 3.15 overview, Python 3.15 introduces several language additions and performance diagnostics tools designed to improve startup times and code ergonomics.
Explicit Lazy Imports (PEP 810)
Python 3.15 adds explicit lazy imports via syntax like lazy import json and lazy from pathlib import Path. According to the source, this delays module importation until specific symbols are actually invoked in subsequent code.
- Example: Writing
lazy import jsondefers loading the module until a function fromjsonis called. - Practical Implication: Developers building command-line tool plugins can mitigate startup performance penalties caused by heavy dependencies (such as
sentence_transformers) without building manual workarounds.
Unpacking in Comprehensions (PEP 798)
The release extends PEP 448 unpacking syntax by supporting unpacking directly inside list, set, and dictionary comprehensions.
- Example: Developers can write code formatted as
[*sublist for sublist in lists]. - Practical Implication: This syntax simplifies the code required to flatten nested collections.
Built-In Sampling Profiler (Tachyon)
Python 3.15 updates the tracing profiler naming for cProfile to profiling.tracing and introduces a low-overhead built-in sampling profiler called Tachyon (profiling.sampling).
- Example: The profiler captures stack traces from running processes without requiring prior code instrumentation.
- Practical Implication: Developers can perform low-overhead performance analysis and generate flame graphs directly from the standard library, removing the need for external tools like
py-spy.
Python 3.10 End of Life and Version Support Shifts
The release of Python 3.15 officially ends support for Python 3.10.
- Practical Implication: Developers maintaining multi-version open-source projects can drop Python 3.10 and adopt features from Python 3.11 onwards. This enables native usage of
tomllib,asyncio.TaskGroup,asyncio.timeout(),datetime.UTC, and SQLite updates likesetlimit(),create_window_function(), andblobopen().
Limitations
- Performance Parity: The source notes that core Python 3.15 performance is largely identical to Python 3.14. Only the experimental Just-In-Time (JIT) compiler provides a measured speedup, offering about a 1.2x boost on a Fibonacci test.
- Platform Constraints: Using utilities like the sampling profiler on specific operating systems, such as macOS, may require elevated privileges (
sudo) to attach to target process IDs.