Lazy loading has landed!

Hello! Sorry for resurrecting an old thread; let me know if a new thread would be better.

I’m co-author of PEP 690, a core CPython PEP that would integrate lazy imports more deeply into the language. You can read the PEP at PEP 690 – Lazy Imports | peps.python.org and a very long discussion thread at PEP 690: Lazy Imports - PEPs - Discussions on Python.org

If PEP 690 existed, I think lazy.attach etc would not be required, and e.g. skimage/filters/__init__.py could just contain a series of normal import statements of its submodules, which PEP 690 could make lazy.

Currently the PEP is geared towards application developers making imports in their application lazy, not so much libraries making their own internal imports lazy by default, for e.g. interactive use. If “lazy by default” is important here, it may require adding something to the PEP to allow a module to declare all imports within it lazy by default.

Would welcome comments on the PEP from anyone involved in lazy importing in the scientific Python community.

1 Like