-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
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 |
importlib.util._LazyModule.__getattribute__
to special-case requests for __spec__
.importlib.util._LazyModule.__getattribute__
to special-case requests for __spec__
Sounds great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs at least a news entry and doc changes.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
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
.