Skip to content

gh-154675: reorganize some imports in importlib - #154657

Merged
brettcannon merged 5 commits into
python:mainfrom
brettcannon:lazy-importlib
Jul 27, 2026
Merged

gh-154675: reorganize some imports in importlib#154657
brettcannon merged 5 commits into
python:mainfrom
brettcannon:lazy-importlib

Conversation

@brettcannon

@brettcannon brettcannon commented Jul 24, 2026

Copy link
Copy Markdown
Member

@brettcannon brettcannon self-assigned this Jul 24, 2026
@hugovk hugovk changed the title Use lazy imports in the top-level modules of importlib gh-154675: Use lazy imports in the top-level modules of importlib Jul 25, 2026
@hugovk hugovk removed the skip issue label Jul 25, 2026
@hugovk

hugovk commented Jul 25, 2026

Copy link
Copy Markdown
Member

No objection to tidying the imports here, but I don't see much if any time saved here: _imp is a builtin and already loaded, warnings was already deferred.

We could get some good savings from importlib.resources (15ms -> 8ms) and importlib.metadata (10ms -> 7ms), but should also consider the backports.

Comment thread Lib/importlib/util.py
@brettcannon

Copy link
Copy Markdown
Member Author

_imp is a builtin and already loaded

Good catch! I've reverted it.

warnings was already deferred.

True, but it bugged me enough that I've been wanting to make this change to the import since lazy imports were announced, so I consider it clean-up along with making the re-exporting more obvious.

We could get some good savings from importlib.resources (15ms -> 8ms) and importlib.metadata (10ms -> 7ms), but should also consider the backports.

I view that as a call for @jaraco to make as that's mostly their code.

@brettcannon brettcannon changed the title gh-154675: Use lazy imports in the top-level modules of importlib gh-154675: reorganize some imports in importlib Jul 27, 2026
@brettcannon
brettcannon enabled auto-merge (squash) July 27, 2026 19:49
@brettcannon
brettcannon merged commit 0284ce8 into python:main Jul 27, 2026
47 checks passed
@brettcannon
brettcannon deleted the lazy-importlib branch July 27, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants