Skip to content

Commit 58832f2

Browse files
authored
Merge pull request #502 from danielhollas/defer-zipp
Defer import of zipp
2 parents 5dd80c3 + e3ce33b commit 58832f2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

importlib_metadata/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
from itertools import starmap
3030
from typing import Any, Iterable, List, Mapping, Match, Optional, Set, cast
3131

32-
from zipp.compat.overlay import zipfile
33-
3432
from . import _meta
3533
from ._collections import FreezableDefaultDict, Pair
3634
from ._compat import (
@@ -777,6 +775,9 @@ def children(self):
777775
return []
778776

779777
def zip_children(self):
778+
# deferred for performance (python/importlib_metadata#502)
779+
from zipp.compat.overlay import zipfile
780+
780781
zip_path = zipfile.Path(self.root)
781782
names = zip_path.root.namelist()
782783
self.joinpath = zip_path.joinpath

newsfragments/502.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deferred import of zipfile.Path

0 commit comments

Comments
 (0)