mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-12414: Update code_sizeof() to take in account co_extra memory. (#1168)
This commit is contained in:
parent
58f3c9dc8f
commit
b4dc6af7a7
4 changed files with 16 additions and 5 deletions
|
@ -922,13 +922,15 @@ class SizeofTest(unittest.TestCase):
|
|||
return inner
|
||||
check(get_cell().__closure__[0], size('P'))
|
||||
# code
|
||||
check(get_cell().__code__, size('6i13P'))
|
||||
check(get_cell.__code__, size('6i13P'))
|
||||
def check_code_size(a, expected_size):
|
||||
self.assertGreaterEqual(sys.getsizeof(a), expected_size)
|
||||
check_code_size(get_cell().__code__, size('6i13P'))
|
||||
check_code_size(get_cell.__code__, size('6i13P'))
|
||||
def get_cell2(x):
|
||||
def inner():
|
||||
return x
|
||||
return inner
|
||||
check(get_cell2.__code__, size('6i13P') + calcsize('n'))
|
||||
check_code_size(get_cell2.__code__, size('6i13P') + calcsize('n'))
|
||||
# complex
|
||||
check(complex(0,1), size('2d'))
|
||||
# method_descriptor (descriptor object)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue