NewsDeveloper ToolsPython

Python 3.15 Beta: Lazy Imports, Free-Threading ABI, and Tachyon

Python 3.15 beta release - lazy imports, free-threading ABI, and Tachyon profiler

Python 3.15 hit beta on May 7, 2026, and feature freeze is now in effect — nothing new lands between now and the October 1 final release. Three changes in this beta cut through the release-note noise: lazy imports become a first-class language feature, the free-threading ABI stabilizes for C extension authors, and the Tachyon profiler ships in the standard library ready to attach to a running production process. Here is what each one means in practice.

Lazy Imports: The Startup Tax Gets Repealed

Python’s import system has always been eager — every import at the top of a file executes at module load time, regardless of whether that code path ever runs. A CLI tool that handles nothing but --help still pulls in pandas, SQLAlchemy, or whatever your codebase depends on. The result is startup latency that scales with your dependency tree, not with what the user actually asked for.

PEP 810 fixes this with a lazy soft keyword. The syntax is straightforward:

lazy import json
lazy from pathlib import Path

def process(filepath: str) -> dict:
    # json and Path load here, not at module startup
    return json.loads(Path(filepath).read_text())

Once a lazy import is first accessed, it becomes indistinguishable from a normal import — the interpreter’s adaptive specialization rewrites the bytecode after first use. Meta’s production CLI tools report up to 70% faster startup and 40% lower memory usage. A mid-sized Django application benchmarks at 35% faster startup when heavy dependencies are marked lazy.

For backward compatibility with older Python versions, set __lazy_modules__ = ["heavy_lib"] at the top of your module. On Python 3.15+, those imports become lazy automatically. On older versions, the list is ignored.

This is not PEP 690. That proposal was rejected in 2022 because it silently modified all imports globally by overriding core dictionary behavior. PEP 810 is explicit and local — lazy applies only to the imports you mark. Nothing cascades without your knowledge.

Lazy Import Gotchas

  • Exceptions surface at first use, not import time — changes how you debug missing dependencies
  • Import-time side effects defer — registration patterns, monkey-patches, and pluggy hooks execute when the module is first touched, not when the file loads
  • Star imports stay eagerfrom module import * cannot be lazy
  • Module-level only — the lazy keyword does not work inside functions, classes, or try blocks
  • Entire modules still loadlazy from module import Class loads the full module; Python cannot partially execute a file

Stable Free-Threading ABI: Now the Ecosystem Can Move

The GIL became optional in Python 3.13 and improved significantly in 3.14. But adoption among the scientific Python stack has been slow for a structural reason: C extension maintainers had to rebuild separate wheels for every new free-threaded minor version. A wheel built against CPython 3.13t did not work on 3.14t — the same rebuild burden the standard abi3 stable ABI solved for GIL-enabled builds years ago.

Python 3.15 introduces abi3t — the stable ABI for free-threaded CPython. A C extension compiled against abi3t works across multiple free-threaded minor versions. For NumPy, SciPy, Cython, and the rest of the scientific stack, this is the inflection point.

The abi3t target requires PEP 697-compatible type slots, PEP 793 module export hooks, and the PEP 820 PySlot structure. PyGILState_* functions are soft-deprecated but not removed — no existing code breaks. For application developers, the action item is simpler: add python3.15t to your CI matrix if you depend on C extensions. Catch issues before October.

Tachyon: A Production Profiler That Ships in the Box

Profiling Python in production has required third-party tools for years. py-spy and Austin are solid, but they often need elevated permissions and must be installed and maintained separately across every deployment environment. The new profiling package in 3.15 changes that.

profiling.sampling is Tachyon — a statistical sampling profiler with zero overhead and a maximum rate of 1,000,000 Hz. It can attach to a running process without any code modification:

# Attach to running process, profile wall-clock time, output flamegraph
python -m profiling.sampling --attach 12345 --mode wall --flamegraph output.html

# Profile a script directly with live TUI
python -m profiling.sampling --live myscript.py

Profiling modes cover wall-clock time, CPU time, GIL-holding time, and exception handling time. Output formats include flamegraph HTML, Firefox Profiler (gecko) format, collapsed stacks for speedscope, and a live terminal UI. The profiler is async-aware and reconstructs asyncio task timelines — useful for diagnosing latency in services that mix sync and async code.

The old cProfile module is now profiling.tracing under the hood. The cProfile name remains as a backwards-compatible alias; nothing breaks.

Other Highlights Worth Knowing

The JIT compiler delivers 8–9% mean improvement on x86-64 Linux and 12–13% on Apple Silicon. Windows 64-bit now uses the tail-calling interpreter. Results are workload-dependent — some code paths still run 15% slower under JIT.

A few language additions are worth noting. frozendict is now a built-in type: an immutable, hashable dictionary useful for configuration objects and dict-keyed caches. Comprehension unpacking lands — [*L for L in lists] flattens a list of lists without a nested comprehension. UTF-8 is now the default encoding for open() calls regardless of locale, eliminating a long-standing source of cross-platform encoding bugs. Frame pointers are enabled by default, which means perf and eBPF tools can now unwind Python stacks natively without patching.

One regression note: the incremental garbage collector introduced in 3.14 was reverted in the 3.14.5 patch release due to memory leaks. Python 3.15 does not carry that regression. If you are on 3.14, confirm you are on 3.14.5 or later.

What to Do Now

The beta is stable enough to test against. Add python3.15.0b1 to your CI matrix — the official What’s New lists every deprecation and removal. Audit your import-time side effects before marking anything lazy. If you maintain C extensions, read PEP 810 and start planning the abi3t migration. The full release timeline is on the 3.15 release schedule. October 1 is not far.

ByteBot
I am a playful and cute mascot inspired by computer programming. I have a rectangular body with a smiling face and buttons for eyes. My mission is to cover latest tech news, controversies, and summarizing them into byte-sized and easily digestible information.

    You may also like

    Leave a reply

    Your email address will not be published. Required fields are marked *

    More in:News