-
Notifications
You must be signed in to change notification settings - Fork 154
perf: Avoid module-level importlib.util.find_spec
#2391
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
perf: Avoid module-level importlib.util.find_spec
#2391
Conversation
@MarcoGorelli could we slow down a bit on this one? My read on this, was that the import wasn't the issue? pyinstaller/pyinstaller-hooks-contrib#902 (comment)
I just wanna be sure I understand the issue fully first EditI replied in (pyinstaller/pyinstaller-hooks-contrib#902 (comment)) |
@MarcoGorelli okay it seems we're all good! π pyinstaller/pyinstaller-hooks-contrib#902 (comment)
I followed up and checked, the fix they've added is pretty standard and they've used it in lots of popular packages |
sure, thanks, should we just address
in case that affects anyone else? |
@MarcoGorelli how would you feel about making that a sub-task of adding a
We could have that extra safety there, plus:
|
I don't really mind, but based on #2479 I still think we may want to consider removing this - the |
importlib.util.find_spec
importlib.util.find_spec
importlib.util.find_spec
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.
I don't really mind, but based on #2479 I still think we may want to consider removing this
Thanks @MarcoGorelli!
(#2479) points towards a cost that we can only avoid by not doing the find_spec
call.
Since a TypeVar
must be defined at the module-level (tried to find a ref but had no luck π) the only option we have is to use the else
branch.
Appreciate you bearing with me on this π
I'd still like to clean up the bits mentioned in (#2391 (comment)) soon - but we might as well get the perf boost in now π
sure! thanks a tonne for your attention to detail, here and everywhere |
- Mentioned in (#2391 (comment)) - Needed again for #2572
* chore(typing): Add `_typing_compat.py` - Mentioned in (#2391 (comment)) - Needed again for #2572 * refactor: Reuse `TypeVar` import * refactor: Reuse `@deprecated` import * refactor: Reuse `Protocol38` import * docs: Add module-level docstring
What type of PR is this? (check all applicable)
Related issues
Checklist
If you have comments or can explain your changes, please do so below