Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
gh-75876: Correct the memory use declared by two bigmem tests
repr() of a list or a tuple of 2**31 False takes 15.3 bytes per item, not 15,
and str.split() takes 10.7 bytes per item and more for a larger string, not 10.
The difference is small, but it grows with the size of the test: 614 MiB for
test_repr_large.
  • Loading branch information
serhiy-storchaka committed Aug 20, 2026
commit 78b6deaeb8c8335331e5a12a15e0a55473c6001f
10 changes: 5 additions & 5 deletions Lib/test/test_bigmem.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def test_split_small(self, size):
# suffer for the list size. (Otherwise, it'd cost another 48 times
# size in bytes!) Nevertheless, a list of size takes
# 8*size bytes.
@bigmemtest(size=_2G + 5, memuse=ascii_char_size * 2 + pointer_size)
@bigmemtest(size=_2G + 5, memuse=ascii_char_size * 3 + pointer_size)
def test_split_large(self, size):
_ = self.from_latin1
s = _(' a') * size + _(' ')
Expand Down Expand Up @@ -936,11 +936,11 @@ def basic_test_repr(self, size):
self.assertEqual(s[:10], '(False, Fa')
self.assertEqual(s[-10:], 'se, False)')

@bigmemtest(size=_2G // 7 + 2, memuse=pointer_size + ascii_char_size * 7)
@bigmemtest(size=_2G // 7 + 2, memuse=pointer_size + ascii_char_size * 8)
def test_repr_small(self, size):
return self.basic_test_repr(size)

@bigmemtest(size=_2G + 2, memuse=pointer_size + ascii_char_size * 7)
@bigmemtest(size=_2G + 2, memuse=pointer_size + ascii_char_size * 8)
def test_repr_large(self, size):
return self.basic_test_repr(size)

Expand Down Expand Up @@ -1115,11 +1115,11 @@ def basic_test_repr(self, size):
self.assertEqual(s[-10:], 'se, False]')
self.assertEqual(s.count('F'), size)

@bigmemtest(size=_2G // 7 + 2, memuse=pointer_size + ascii_char_size * 7)
@bigmemtest(size=_2G // 7 + 2, memuse=pointer_size + ascii_char_size * 8)
def test_repr_small(self, size):
return self.basic_test_repr(size)

@bigmemtest(size=_2G + 2, memuse=pointer_size + ascii_char_size * 7)
@bigmemtest(size=_2G + 2, memuse=pointer_size + ascii_char_size * 8)
def test_repr_large(self, size):
return self.basic_test_repr(size)

Expand Down