mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-127274: Defer nested methods (#128012)
Methods (functions defined in class scope) are likely to be cleaned up by the GC anyway. Add a new code flag, `CO_METHOD`, that is set for functions defined in a class scope. Use that when deciding to defer functions.
This commit is contained in:
parent
e163e8d4e1
commit
255762c09f
11 changed files with 37 additions and 14 deletions
|
@ -850,12 +850,6 @@ class ReturnRecorder:
|
|||
def __call__(self, code, offset, val):
|
||||
self.events.append(("return", code.co_name, val))
|
||||
|
||||
# gh-127274: CALL_ALLOC_AND_ENTER_INIT will only cache __init__ methods that
|
||||
# are deferred. We only defer functions defined at the top-level.
|
||||
class ValueErrorRaiser:
|
||||
def __init__(self):
|
||||
raise ValueError()
|
||||
|
||||
|
||||
class ExceptionMonitoringTest(CheckEvents):
|
||||
|
||||
|
@ -1054,6 +1048,9 @@ class ExceptionMonitoringTest(CheckEvents):
|
|||
|
||||
@requires_specialization_ft
|
||||
def test_no_unwind_for_shim_frame(self):
|
||||
class ValueErrorRaiser:
|
||||
def __init__(self):
|
||||
raise ValueError()
|
||||
|
||||
def f():
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue