Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c7181d

Browse files
Optimize the test for issue #13454.
Now it requires almost 4x less memory and is almost 2x faster.
2 parents 73e3880 + 5bb893c commit 1c7181d

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

Lib/test/test_itertools.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,10 +1269,8 @@ def test_tee(self):
12691269

12701270
# Issue 13454: Crash when deleting backward iterator from tee()
12711271
def test_tee_del_backward(self):
1272-
forward, backward = tee(range(20000000))
1273-
for i in forward:
1274-
pass
1275-
1272+
forward, backward = tee(repeat(None, 20000000))
1273+
any(forward) # exhaust the iterator
12761274
del backward
12771275

12781276
def test_StopIteration(self):

0 commit comments

Comments
 (0)