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

@brettcannonbrettcannon commented Jul 24, 2026

Copy link
Copy Markdown
Member

@brettcannonbrettcannon self-assigned this Jul 24, 2026
@hugovkhugovk changed the title Use lazy imports in the top-level modules of importlibgh-154675: Use lazy imports in the top-level modules of importlibJul 25, 2026
@hugovk

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 threadLib/importlib/util.py
@brettcannon

Copy link
Copy Markdown
MemberAuthor

_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.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@brettcannon@hugovk@StanFromIreland