diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index 6dfaad0c..9b912f8e 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -29,8 +29,6 @@ from itertools import starmap from typing import Any, Iterable, List, Mapping, Match, Optional, Set, cast -from zipp.compat.overlay import zipfile - from . import _meta from ._collections import FreezableDefaultDict, Pair from ._compat import ( @@ -777,6 +775,9 @@ def children(self): return [] def zip_children(self): + # deferred for performance (python/importlib_metadata#502) + from zipp.compat.overlay import zipfile + zip_path = zipfile.Path(self.root) names = zip_path.root.namelist() self.joinpath = zip_path.joinpath diff --git a/newsfragments/502.feature.rst b/newsfragments/502.feature.rst new file mode 100644 index 00000000..20659bb8 --- /dev/null +++ b/newsfragments/502.feature.rst @@ -0,0 +1 @@ +Deferred import of zipfile.Path \ No newline at end of file