Skip to content

[3.15] gh-148587: Make sys.lazy_modules match PEP and keep internal lazy submodules tra…#150014

Draft
DinoV wants to merge 2 commits into
python:3.15from
DinoV:lazy_modules
Draft

[3.15] gh-148587: Make sys.lazy_modules match PEP and keep internal lazy submodules tra…#150014
DinoV wants to merge 2 commits into
python:3.15from
DinoV:lazy_modules

Conversation

@DinoV
Copy link
Copy Markdown
Contributor

@DinoV DinoV commented May 18, 2026

The PEP initially set sys.lazy_modules was to be a set of the lazily imported things. At some point it seemed that having our internal tracking for publishing submodules to parent modules when they're imported could be combined with this. But this means that data the interpreter is making decisions on is now immutable. This goes back to having a separate set for the lazy modules which is user visible but has no impact on how lazy imports are evaluated or executed.

This is one possible approach - another one would be to make it a function and calculate the set and return it per-call. Then it would be backed by our normal internal data.

We could also make it a function and keep tracking both sets of data as this PR does and then that'd give us the ability in the future to lazily calculate the data.

@DinoV DinoV changed the title Make sys.lazy_modules match PEP and keep internal lazy submodules tra… gh-148587: Make sys.lazy_modules match PEP and keep internal lazy submodules tra… May 18, 2026
@DinoV DinoV changed the title gh-148587: Make sys.lazy_modules match PEP and keep internal lazy submodules tra… [3.15] gh-148587: Make sys.lazy_modules match PEP and keep internal lazy submodules tra… May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant