
"Python programs are set to get faster startup times with PEP 810 "Explicit lazy imports," which allows scripts to defer loading imported libraries until they're actually needed rather than at startup. The Python Enhancement Proposal (PEP) was put forward by Pablo Salgadoon, Steering Council Member, on October 3 and approved November 3. The enhancement will bring lazy imports into the Python language itself, as an opt-in feature."
"Importing modules in Python is both a boon and a pain. A boon, because a few import statements can hugely extend the functionality of a program, but a pain because the symbols imported might never get used, potentially increasing the start-up time. A good example of this would be invoking a program from the command line with something like --help and having to wait while imports are loaded that aren't required. As a solution, lazy imports defer things until they are actually needed."
"This isn't a new notion, but previous attempts failed. PEP 690 was rejected partly because it made lazy imports the default, raising concerns about community fragmentation and backward compatibility. Meanwhile, developers created their own workarounds, with some organizations even forking CPython. PEP 810 succeeds by making lazy imports opt-in, preserving backward compatibility while standardizing what's currently a fragmented landscape of custom solutions."
PEP 810, titled "Explicit lazy imports," was published on October 3 and approved November 3. The feature allows scripts to defer loading imported libraries until they are actually needed, reducing unnecessary startup overhead. Lazy imports are opt-in, preserving backward compatibility and standardizing existing custom workarounds used by some organizations. Previous proposal PEP 690 failed partly because it made lazy imports the default, prompting compatibility concerns and fragmentation. Community responses included over 450 comments and debates over terminology such as "defer" versus "lazy." The approval aims to balance earlier attempts with practical opt-in adoption.
Read at Theregister
Unable to calculate read time
Collection
[
|
...
]