Every program importing shutil pays for that, even if it never creates or extracts an archive and shutil is imported transitively by much of the stdlib: on main, each of urllib.request, tempfile, zipfile, tarfile, http.server and venv ends up with shutil in sys.modules.
Net import cost (median of 40 fresh interpreters):
net cost
import shutil
12.75 ms
import urllib.request
36.64 ms
This matters most for short-lived processes on constrained hardware: CLI tools and serverless cold starts, where a few ms per process is worth removing.
I have a patch with tests that cuts this by ~2.5 ms (−19.6%) on import shutil, and will open a PR.
@StanFromIreland / @aisk
It seems that the PR has been approved but we're missing a review from the core team, do you know who should I ping?
(Not sure about the SLA, so let me know if there is process/policy) Thanks!
Activity
StanFromIreland commented on Jul 30, 2026
(JFYI @aisk, perf improvements are features)
maxday commented on Aug 6, 2026
@StanFromIreland / @aisk
It seems that the PR has been approved but we're missing a review from the core team, do you know who should I ping?
(Not sure about the SLA, so let me know if there is process/policy) Thanks!
gh-154904: Speed up import of shutil by probing compression extension…
pythongh-154904: Speed up import of shutil by probing compression ext…