| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…y imports Add documentation for the __lazy_modules__ module attribute in two places: - Doc/reference/simple_stmts.rst: new subsection under the lazy imports section explaining the compatibility mode, its semantics (module-scope only, overridden by -X lazy_imports=none), and a usage example. - Doc/reference/datamodel.rst: new module.__lazy_modules__ attribute entry with a cross-reference to the detailed explanation in simple_stmts. Also extend the What's New in Python 3.15 lazy-imports entry with a short paragraph and example demonstrating __lazy_modules__.
… docs entry Replace bare __lazy_modules__ in the 3.15.0a8 NEWS entry with :attr:`module.__lazy_modules__` to link to the new attribute documentation. Remove the separate docs NEWS entry; the archive entry serves as the record.
Replace 'migrating a large existing codebase' with the more accurate use case: supporting Python <3.15 while leveraging lazy imports on 3.15+.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
There was a problem hiding this comment.
Small nit
Sorry, something went wrong.
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
| Back | FazBrowse Home | New Git URL |
I'll need some info here, cc @pablogsal @Yhg1s
The PEP reads as if __lazy_modules__ must implement __contains__. The actual implementation supports any iterable, because it uses the classic membership test.
Question: Is it an implementation detail of CPython to support objects beyond containers in __lazy_modules__, and non-containers aren't supported, or do we support any iterable for __lazy_modules__?
Right now I can assign a generator or an old-style __getitem__-based sequence to __lazy_modules__ and CPython will walk it to check membership. Question is whether it's just a CPython thing.
EDIT: ...Hmmm now that I think about it, this makes no sense: a __lazy_modules__ generator will be empty after the first import, rendering all subsequent imports eager. I believe we shouldn't support anything beyond containers. Maybe we could even do this at the runtime level, but maybe if you put a generator to __lazy_modules__ you deserve anything that happens to you.
📚 Documentation preview 📚: https://cpython-previews--148590.org.readthedocs.build/