-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
Following on from #109653, further improvements can be made to import times.
Links to previous discussion of this feature:
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 imports zipfile at the top for a function that won't be called in the vast majority of cases. It also imports importlib.abc, which in turn imports importlib.resources, to subclass an ABC with a single, non-abstract method - I assume redefining the method in importlib.metadata would be harmless. Some other less frequently-used imports which are only accessed once or twice, such as json, could also be tucked away in their calling functions.
Linked PRs
- gh-118761: Improve import time of
pprintÂ?#122725 - gh-118761: Speedup pathlib import by deferring shutilÂ?#123520
- gh-121423: Improve import time of
socketby writingsocket.errorTabas a constant and lazy import modulesÂ?#121424 - gh-118761: Improve import time of
mimetypesÂ?#126979 - gh-118761: improve import time for
pickleÂ?#128732 - gh-118761: substitute
reimport inbase64.b16decodefor a more efficient alternativeÂ?#128736 - gh-118761: improve import time for
secretsÂ?#128738 - gh-118761: Improve import time for
csvÂ?#128858 - gh-118761: Reduce import time of gettext.py by delaying re importÂ?#128898
- gh-118761: improve optparse import time by delaying textwrap importÂ?#128899
- gh-118761: Improve import time of
tomllibÂ?#128907 - gh-118761: Improve import time for
pstatsandzipfileby removing imports totypingÂ?#128981 - gh-118761: Improve import time of
sqlite3Â?#129118 - gh-118761: Improve import time of
subprocessÂ?#129427 - gh-118761: Always lazy import
warningsinthreadingÂ?#129428 - [3.13] gh-118761: Improve import time of
subprocess(GH-129427)Â?#129447 - [3.12] gh-118761: Improve import time of
subprocess(GH-129427)Â?#129448 - gh-118761: Improve import time by lazy import of
warningsÂ?#129765 - gh-118761: Improve import time by lazy import of
tracebackÂ?#129811 - gh-118761: Always lazy import
reinlocaleÂ?#129860 - gh-118761: Improve import time of
dataclassesÂ?#129925 - gh-118761: Improve import time of
cmdmoduleÂ?#130056 - gh-118761: Revert "Improve import time of
subprocess(GH-129427)"Â?#130201 - [3.13] gh-118761: Revert "Improve import time of
subprocess(GH-129427)" (GH-130201)Â?#130204 - [3.12] gh-118761: Revert "Improve import time of
subprocess(GH-129427)" (GH-130201)Â?#130205 - gh-137855: Improve import time of
sqlite3Â?#131796 - gh-118761: Optimise import time for astÂ?#131953
- gh-137855: Optimise import time for textwrapÂ?#131956
- gh-118761: Fix star-import of
astÂ?#132024 - gh-118761: Fix star-import of ast (alternative)Â?#132025
- gh-118761: Improve import time of
annotationlibÂ?#132028 - gh-118761: Use
enum._simple_enumforannotationlib.FormatÂ?#132031 - gh-118761: Cover the import time optimisations in What's NewÂ?#132035
- gh-118761: Optimise import time for
shlexÂ?#132036 - gh-118761: Optimise import time for
stringÂ?#132037 - gh-137855:
email.quoprimimeremovingreimportÂ?#132046 - gh-118761: Defer import of functools in annotationlibÂ?#132059
- gh-118761: Lazily import annotationlib in typingÂ?#132060
- GH-118761: Expose more core interpreter types in
_typesÂ?#132103 - gh-118761: Add helper to ensure that lazy imports are actually lazyÂ?#132614
- gh-118761: Add test_lazy_import for more modulesÂ?#133057
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-featureA feature request or enhancementA feature request or enhancement