mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-30416: Protect the optimizer during constant folding. (#4860)
It no longer spends much time doing complex calculations and no longer consumes much memory for creating large constants that will be dropped later. This fixes also bpo-21074.
This commit is contained in:
parent
a5552f023e
commit
2e3f570185
4 changed files with 144 additions and 27 deletions
|
@ -759,7 +759,8 @@ class CBytesIOTest(PyBytesIOTest):
|
|||
check = self.check_sizeof
|
||||
self.assertEqual(object.__sizeof__(io.BytesIO()), basesize)
|
||||
check(io.BytesIO(), basesize )
|
||||
check(io.BytesIO(b'a' * 1000), basesize + sys.getsizeof(b'a' * 1000))
|
||||
n = 1000 # use a variable to prevent constant folding
|
||||
check(io.BytesIO(b'a' * n), basesize + sys.getsizeof(b'a' * n))
|
||||
|
||||
# Various tests of copy-on-write behaviour for BytesIO.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue