mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
Issue #12911: Fix memory consumption when calculating the repr() of huge tuples or lists.
This introduces a small private API for this common pattern. The issue has been discovered thanks to Martin's huge-mem buildbot.
This commit is contained in:
parent
bb2095f1e2
commit
eeb7eea1f9
13 changed files with 271 additions and 87 deletions
|
@ -154,6 +154,16 @@ class TupleTest(seq_tests.CommonTest):
|
|||
# Trying to untrack an unfinished tuple could crash Python
|
||||
self._not_tracked(tuple(gc.collect() for i in range(101)))
|
||||
|
||||
def test_repr_large(self):
|
||||
# Check the repr of large list objects
|
||||
def check(n):
|
||||
l = (0,) * n
|
||||
s = repr(l)
|
||||
self.assertEqual(s,
|
||||
'(' + ', '.join(['0'] * n) + ')')
|
||||
check(10) # check our checking code
|
||||
check(1000000)
|
||||
|
||||
def test_main():
|
||||
support.run_unittest(TupleTest)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue