-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Improve import time of various stdlib modules #118761
Comments
Sure! |
I've opened a PR over at the
@layday were you planning on tackling these?
This seems to be solved on main, |
importlib.metadata
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
This has been merged and released in version 8.4 of
I've submitted python/importlib_metadata#502 that defers zip import, and python/importlib_metadata#503 which defers |
(removing the 3.14 label since features always target the main branch) |
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <[email protected]>
Feature or enhancement
Proposal:
Following on from #109653, further improvements can be made to import times.
Links to previous discussion of this feature:
https://discuss.python.org/t/deferred-computation-evalution-for-toplevels-imports-and-dataclasses/34173
For example:
importlib.metadata
is often used for tasks that need to happen at import, e.g. to enumerate/load entry point plug-ins, so it might be worth seeing if we can cut down its own import time a bit more.importlib.metadata
importszipfile
at the top for a function that won't be called in the vast majority of cases. It also importsimportlib.abc
, which in turn importsimportlib.resources
, to subclass an ABC with a single, non-abstract method - I assume redefining the method inimportlib.metadata
would be harmless. Some other less frequently-used imports which are only accessed once or twice, such asjson
, could also be tucked away in their calling functions.Linked PRs
pprint
#122725socket
by writingsocket.errorTab
as a constant and lazy import modules #121424mimetypes
#126979The text was updated successfully, but these errors were encountered: