You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
expose an immutable snapshot instead of the live container.
@pablogsal, does it have to be sys.lazy_modules "module-level property" or could it be a function like sys.get_lazy_modules()? Both preserve the concept, but the function fits more here I believe (snapshots should be lazy + open/close principle i.e. we can extend the function in the future to do more useful things in debugging if needed). My instinct is that it would be good to ship it before beta freeze.
Perhaps we are overthinking it since I think we should preserve the simmetry with sys.modules and that's a dictionary.... 🤔
I don't have a strong opinion on this one. @DinoV and @brittanyrey may have practical experience to help them form opinions?
I'm pretty open on how we expose it, but I do think we should expose it.
The idea of it being immutable makes sense to me--but if it's too much of a hassle right now maybe it's okay to expose it as a dict as we do with sys.modules.
This does not need to block beta 1, so moving to deferred-blocker. We can still fix this during the beta, and sooner is better than later, so please try to target b2.
Activity
pablogsal commentedon Apr 25, 2026
@DinoV @Yhg1s WDTY?
pablogsal commentedon Apr 25, 2026
Perhaps we are overthinking it since I think we should preserve the simmetry with
sys.modulesand that's a dictionary.... 🤔@johnslavik what do you think?
johnslavik commentedon Apr 26, 2026
@pablogsal, fair enough -- simple is better than complex. I'll make a public module attribute exposing the frozendict of frozensets from the registry.
pablogsal commentedon May 4, 2026
Marking as release blocker. We need to reach consensus on this before beta freeze @Yhg1s @DinoV
Yhg1s commentedon May 4, 2026
I don't have a strong opinion on this one. @DinoV and @brittanyrey may have practical experience to help them form opinions?
pythongh-148587: Expose live lazy import registry as sys._lazy_modules
johnslavik commentedon May 4, 2026
Filed python/peps#4954.
pythongh-148587: Address review feedback on sys.lazy_modules
pythongh-148587: Trim sys.lazy_modules contract test and NEWS
pythongh-148587: Align sys.__getattr__ with _ctypes/zlib pattern
pythongh-148587: Use METH_VARARGS for sys.__getattr__
pythongh-148587: Pre-size and short-circuit empty in lazy modules sna…
brittanyrey commentedon May 5, 2026
I'm pretty open on how we expose it, but I do think we should expose it.
The idea of it being immutable makes sense to me--but if it's too much of a hassle right now maybe it's okay to expose it as a dict as we do with
sys.modules.hugovk commentedon May 7, 2026
This does not need to block beta 1, so moving to deferred-blocker. We can still fix this during the beta, and sooner is better than later, so please try to target b2.
[3.15] gh-148587: Make sys.lazy_modules match PEP and keep internal l…
johnslavik commentedon May 19, 2026
I believe we should document this too.
gh-148587: Make sys.lazy_modules match PEP and keep internal lazy sub…
Merge branch 'main' into pythongh-148587-doc-sys-lazy-modules
gh-148587: Document `sys.lazy_modules` (#150742)
[3.15] gh-148587: Document `sys.lazy_modules` (GH-150742)