Skip to content

Commit 4759ee9

Browse files
committed
Merge tag 'v1.1.1'
2 parents 3fbe9ea + d8d6c64 commit 4759ee9

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

CHANGES.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v1.1.1
2+
======
3+
4+
#43: Restored performance of implicit dir computation.
5+
16
v2.2.0
27
======
38

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ testing =
2727

2828
# local
2929
jaraco.itertools
30+
func-timeout
3031

3132
docs =
3233
# upstream

test_zipp.py

+7
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import unittest
66
import tempfile
77
import shutil
8+
import string
89

910
import jaraco.itertools
11+
import func_timeout
1012

1113
import zipp
1214

@@ -225,3 +227,8 @@ def test_joinpath_constant_time(self):
225227
entry.joinpath('suffix')
226228
# Check the file iterated all items
227229
assert entries.count == self.HUGE_ZIPFILE_NUM_ENTRIES
230+
231+
@func_timeout.func_set_timeout(3)
232+
def test_implied_dirs_performance(self):
233+
data = ['/'.join(string.ascii_lowercase + str(n)) for n in range(10000)]
234+
zipp.CompleteDirs._implied_dirs(data)

zipp.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ class CompleteDirs(zipfile.ZipFile):
5757
@staticmethod
5858
def _implied_dirs(names):
5959
parents = itertools.chain.from_iterable(map(_parents, names))
60+
# Cast names to a set for O(1) lookups
61+
existing = set(names)
6062
# Deduplicate entries in original order
6163
implied_dirs = OrderedDict.fromkeys(
6264
p + posixpath.sep for p in parents
63-
# Cast names to a set for O(1) lookups
64-
if p + posixpath.sep not in set(names)
65+
if p + posixpath.sep not in existing
6566
)
6667
return implied_dirs
6768

0 commit comments

Comments
 (0)