mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-40222: "Zero cost" exception handling (GH-25729)
"Zero cost" exception handling. * Uses a lookup table to determine how to handle exceptions. * Removes SETUP_FINALLY and POP_TOP block instructions, eliminating (most of) the runtime overhead of try statements. * Reduces the size of the frame object by about 60%.
This commit is contained in:
parent
b32c8e9795
commit
adcd220556
30 changed files with 6614 additions and 5687 deletions
|
|
@ -1273,13 +1273,12 @@ class SizeofTest(unittest.TestCase):
|
|||
check(sys.float_info, vsize('') + self.P * len(sys.float_info))
|
||||
# frame
|
||||
import inspect
|
||||
CO_MAXBLOCKS = 20
|
||||
x = inspect.currentframe()
|
||||
ncells = len(x.f_code.co_cellvars)
|
||||
nfrees = len(x.f_code.co_freevars)
|
||||
extras = x.f_code.co_stacksize + x.f_code.co_nlocals +\
|
||||
ncells + nfrees - 1
|
||||
check(x, vsize('4Pi2c4P3ic' + CO_MAXBLOCKS*'3i' + 'P' + extras*'P'))
|
||||
localsplus = x.f_code.co_stacksize + x.f_code.co_nlocals +\
|
||||
ncells + nfrees
|
||||
check(x, vsize('8P3i3c' + localsplus*'P'))
|
||||
# function
|
||||
def func(): pass
|
||||
check(func, size('14P'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue