PEP 810 Proposes Explicit Lazy Imports for Python 3.15

An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.

  • Sarah Gooding
4 min read
PEP 810 Proposes Explicit Lazy Imports for Python 3.15

Python’s import system could be in for its biggest change in years. A new proposal, PEP 810, landed on October 2, 2025, introducing a lazy keyword to defer imports until first use. Within hours of publication, the idea sparked a surge of attention. A Hacker News thread shot past 353 points with nearly 200 comments in the first 24 hours it was discussed, as developers debated whether faster startup times are worth the risks of shifting when code executes.

What PEP 810 adds

#

PEP 810 defines explicit syntax for lazy imports:

Python
lazy import json
lazy from json import dumps

Unlike normal imports, these statements bind a proxy object that only resolves when first used. Until then, the module isn’t loaded or added to sys.modules. The design is local, explicit, and granular: only imports marked with lazy are affected, and nothing cascades into submodules unless specified:

Lazy imports are controlled, in the sense that deferred loading is only triggered by the importing code itself. In the general case, a library will only experience lazy imports if its own authors choose to mark them as such. This avoids shifting responsibility onto downstream users and prevents accidental surprises in library behavior. Since library authors typically manage their own import subgraphs, they retain predictable control over when and how laziness is applied.
The mechanism is also granular. It is introduced through explicit syntax on individual imports, rather than a global flag or implicit setting. This allows developers to adopt it incrementally, starting with the most performance-sensitive areas of a codebase. As this feature is introduced to the community, we want to make the experience of onboarding optional, progressive, and adaptable to the needs of each project.

For large applications or tools with sprawling dependency graphs, the benefit is faster startup and reduced baseline memory. For type hints, lazy also removes the need for if TYPE_CHECKING: guards, since unused imports no longer carry a runtime cost.

How it differs from PEP 690

#

Python has been down this road before. In 2022, PEP 690 proposed global lazy imports, but the Steering Council rejected it over complexity and unpredictability. PEP 810 takes the opposite tack: everything is explicit. Imports remain eager unless the lazy keyword is present.

The new PEP also avoids hooking into core dictionary lookups, a controversial design choice in 690, instead using lightweight proxy objects. A global flag and filter API are available for those who want to experiment broadly, but the baseline model is opt-in, one import at a time.

Benefits for CLI tools

#

The strongest case for lazy imports is command-line tools. Developers pointed out that even a simple --help command can drag in dozens of modules, sometimes blocking on heavy dependencies like PyTorch.

“My llm.datasette.io CLI tool supports plugins, and people were complaining about really slow start times even for commands like llm --help — it turned out there were popular plugins that did things like import pytorch at the base level, so the entire startup was blocked on heavy imports,” Simon Willison commented. “Having a core Python language feature for this would be really nice.”

The PEP itself notes that lazy imports can cut startup time by 50–70% in practice, a dramatic improvement for CLIs, test runners, and other tools where responsiveness matters. Advocates say this could make Python more competitive in domains where startup latency has traditionally been a weakness.

Risks and trade-offs

#

Not everyone is convinced. Some developers warn that late errors, exceptions that would normally appear at startup, will now be deferred until first use, sometimes deep into a long-running process. Others highlight thread-safety concerns: code that used to run predictably during single-threaded startup may now be executed in any thread that first touches the lazy import.

“I think they're understating the thread safety risks here,” wrote one commenter. “Lazy loading is going to unearth these errors in the most inconvenient way (as Heisenbugs).”

There’s also debate over syntax. Some feel adding a new keyword makes Python noisier, while others argue that explicitness matches the language’s philosophy. One commenter said: “I don't hate it but I don't love it. It sounds like everyone will start writing lazy before essentially every single import… That makes Python code visually noisier.”

Mixed reactions from the community

#

The Hacker News thread shows clear enthusiasm mixed with caution. Supporters praised the PEP as “one of the cleanest in a while,” commending its scoped, opt-in design. Skeptics countered that Python imports have unavoidable side effects, and moving them later in execution risks subtle breakage.

“This will break tons of code and introduce a slew of footguns,” warned one critic. “Import statements fundamentally have side effects, and when and how these side effects are applied will cause mysterious problems and breakages that will keep people up for many nights.”

Despite the debate, many agreed on one point: CLI tools stand to benefit the most. “Startup time is very important to me,” another commenter wrote. “I will certainly be using it in my own code if the PEP is accepted.”

Draft status and next steps

#

PEP 810 is still a Draft targeting Python 3.15. The Steering Council will weigh it after community discussion on Discourse and elsewhere. Given the rejection of PEP 690, the explicit, opt-in design may give this attempt a better chance.

For now, the lively Hacker News debate shows that import performance, something often hidden in the background, remains a hot-button issue for Python developers.

Stay ahead of threats

Subscribe to our newsletter

Get notified when we publish new security blog posts!