PEP 810 – Explicit lazy imports | peps.python.org
Lazy imports defer the loading and execution of a module until the first time the imported name is used, in contrast to ‘normal’ imports, which eagerly load and execute a module at the point of the import statement. By allowing developers to mark individual imports as lazy with explicit syntax, Python programs can reduce startup time, memory usage, and unnecessary work. This is particularly beneficial for command-line tools, test suites, and applications with large dependency graphs. This proposal preserves full backwards compatibility: normal import statements remain unchanged, and lazy imports are enabled only where explicitly requested. The dominant convention in Python code is to place all imports at the module level, typically at the beginning of the file. This avoids repetition, makes import dependencies clear and minimizes runtime overhead by only evaluating an import statement once per module. A major drawback with this approach is that importing the first module for an executi
PEP 810 – Explicit lazy imports | peps.python.org Selected dark colour scheme Selected light colour scheme PEP 810 – Explicit lazy imports PEP 810 – Explicit lazy imports Author : Pablo Galindo Salgado <pablogsal at python.org>, Germán Méndez Bravo <german.mb at gmail.com>, Thomas Wouters <thomas at python.org>, Dino Viehland <dinoviehland at gmail.com>, Brittany Reynoso <brittanyrey at gmail.com>, Noah Kim <noahbkim at gmail.com>, Tim Stumbaugh <me at tjstum.com> Discussions-To : Discourse thread Status : Acce
Explore this link on the map →saved by
related reading
- styleguide | Style guides for Google-originated open-source projectsgoogle.github.io
- PEP 703 – Making the Global Interpreter Lock Optional in CPython | peps.python.orgpeps.python.org
- Lazy loading - Performance | MDNdeveloper.mozilla.org
- The Global Object Patternpython-patterns.guide
- Modern Python performance considerations [LWN.net]lwn.net
- Glossary — Python 3.14.6 documentationdocs.python.org
- Behind The Scenes of Bun Install | Bun Blogbun.com
- Pyrefly vs. ty: Comparing Python’s Two New Rust-Based Type Checkers | Edward Li's Blogblog.edward-li.com
- Libraries: OxRSE Trainingtrain.oxrse.uk
- "We're building a new static type checker for Python" | Hacker Newsnews.ycombinator.com
- Python, type hints, and future annotationsblog.derlin.ch
- A Lean Syntax Primer — overreactedoverreacted.io