Skip to content

Commit 7afe4e1

Browse files
Update comments.
1 parent 54dfd58 commit 7afe4e1

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Lib/test/pickletester.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,14 @@ def test_negative_32b_binput(self):
11641164

11651165
def test_too_large_put(self):
11661166
# Test that PUT with large id does not cause allocation of
1167-
# too large memo table.
1167+
# too large memo table. The C implementation uses a dict-based memo
1168+
# for sparse indices (when idx > memo_len * 2) instead of allocating
1169+
# a massive array. This test verifies large sparse indices work without
1170+
# causing memory exhaustion.
1171+
#
1172+
# The following simple pickle creates an empty list, memoizes it
1173+
# using a large index, then loads it back on the stack, builds
1174+
# a tuple containing 2 identical empty lists and returns it.
11681175
data = lambda n: (b'((lp' + str(n).encode() + b'\n' +
11691176
b'g' + str(n).encode() + b'\nt.')
11701177
# 0: ( MARK
@@ -1186,7 +1193,9 @@ def test_too_large_long_binput(self):
11861193
# a massive array. This test verifies large sparse indices work without
11871194
# causing memory exhaustion.
11881195
#
1189-
# If the threshold formula changes, ensure test indices still exceed it.
1196+
# The following simple pickle creates an empty list, memoizes it
1197+
# using a large index, then loads it back on the stack, builds
1198+
# a tuple containing 2 identical empty lists and returns it.
11901199
data = lambda n: (b'(]r' + struct.pack('<I', n) +
11911200
b'j' + struct.pack('<I', n) + b't.')
11921201
# 0: ( MARK

0 commit comments

Comments
 (0)