flâneur — a map of the web's best reading

PEP 810 – Explicit lazy imports | peps.python.org

peps.python.org · 13,047 words · saved by 1 readers

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&#32;&#97;t&#32;python.org>, Germán Méndez Bravo <german.mb&#32;&#97;t&#32;gmail.com>, Thomas Wouters <thomas&#32;&#97;t&#32;python.org>, Dino Viehland <dinoviehland&#32;&#97;t&#32;gmail.com>, Brittany Reynoso <brittanyrey&#32;&#97;t&#32;gmail.com>, Noah Kim <noahbkim&#32;&#97;t&#32;gmail.com>, Tim Stumbaugh <me&#32;&#97;t&#32;tjstum.com> Discussions-To : Discourse thread Status : Acce

Explore this link on the map →

saved by

related reading