-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
gh-127036: Update importlib.util._LazyModule.__getattribute__
to special-case requests for __spec__
.
#127038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
gh-127036: Update importlib.util._LazyModule.__getattribute__
to special-case requests for __spec__
.
#127038
Conversation
Allow `importlib.util._LazyModule` to special-case its `__spec__` attribute so that the regular import machinery requesting that attribute doesn't trigger the full module load.
A few things I'm unsure of:
|
I think so since it changes the semantics and someone may have been relying on it.
I think what you already have in the PR suffices as it verifies things are working. |
And apologies for taking so long to get to this PR! |
FYI my approval is still gated on a news entry thanks to CI checking for it. |
Cheers! Looking at this with fresh eyes, the semantic change definitely warrants more than just a code change. In addition to the news entry, I'll attempt to tweak the |
Allow
importlib.util._LazyModule
to special-case its__spec__
attribute so that when the regular import machinery requests that attribute, it doesn't trigger the full module load. This will make it easier to useimportlib.util.LazyLoader
.