Skip to content

Commit

Permalink
GH-109653: Defer import of importlib.metadata._adapters (python/c…
Browse files Browse the repository at this point in the history
…python#109829)

---------

Co-authored-by: Jason R. Coombs <[email protected]>
  • Loading branch information
AA-Turner and jaraco committed Mar 21, 2024
1 parent 0db550c commit ca03a4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions importlib_resources/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from typing import Union, Optional, cast
from .abc import ResourceReader, Traversable

from .future.adapters import wrap_spec

Package = Union[types.ModuleType, str]
Anchor = Package

Expand Down Expand Up @@ -111,6 +109,9 @@ def from_package(package: types.ModuleType):
Return a Traversable object for the given package.
"""
# deferred for performance (python/cpython#109829)
from .future.adapters import wrap_spec

spec = wrap_spec(package)
reader = spec.loader.get_resource_reader(spec.name)
return reader.files()
Expand Down
1 change: 1 addition & 0 deletions newsfragments/+.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deferred select imports in for a speedup (python/cpython#109829).

0 comments on commit ca03a4d

Please sign in to comment.