You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
argparse currently defers importing copy, difflib, shutil, textwrap, and warnings using inline imports, while importing re and gettext eagerly at module scope. I think these can safely be replaced with module-level explicit lazy imports, which will make the module’s dependencies more readable and reduce the cost of a bare import argparse.
On my machine, preliminary release-build measurements using -S -X importtime show the median cumulative import time for argparse decreasing by approximately 67%, from 4,792 µs to 1,595 µs across 15 alternating runs.
Activity
GH-154638: Use lazy imports in argparse (#154639)
pythonGH-154638: Use lazy imports in argparse (python#154639)