File tree 4 files changed +16
-2
lines changed
4 files changed +16
-2
lines changed Original file line number Diff line number Diff line change
1
+ v1.1.1
2
+ ======
3
+
4
+ #43: Restored performance of implicit dir computation.
5
+
1
6
v2.2.0
2
7
======
3
8
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ testing =
27
27
28
28
# local
29
29
jaraco.itertools
30
+ func-timeout
30
31
31
32
docs =
32
33
# upstream
Original file line number Diff line number Diff line change 5
5
import unittest
6
6
import tempfile
7
7
import shutil
8
+ import string
8
9
9
10
import jaraco .itertools
11
+ import func_timeout
10
12
11
13
import zipp
12
14
@@ -225,3 +227,8 @@ def test_joinpath_constant_time(self):
225
227
entry .joinpath ('suffix' )
226
228
# Check the file iterated all items
227
229
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 )
Original file line number Diff line number Diff line change @@ -57,11 +57,12 @@ class CompleteDirs(zipfile.ZipFile):
57
57
@staticmethod
58
58
def _implied_dirs (names ):
59
59
parents = itertools .chain .from_iterable (map (_parents , names ))
60
+ # Cast names to a set for O(1) lookups
61
+ existing = set (names )
60
62
# Deduplicate entries in original order
61
63
implied_dirs = OrderedDict .fromkeys (
62
64
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
65
66
)
66
67
return implied_dirs
67
68
You can’t perform that action at this time.
0 commit comments