mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +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
|
@ -138,6 +138,13 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block,
|
|||
|
||||
ste->ste_has_docstring = 0;
|
||||
|
||||
ste->ste_method = 0;
|
||||
if (st->st_cur != NULL &&
|
||||
st->st_cur->ste_type == ClassBlock &&
|
||||
block == FunctionBlock) {
|
||||
ste->ste_method = 1;
|
||||
}
|
||||
|
||||
ste->ste_symbols = PyDict_New();
|
||||
ste->ste_varnames = PyList_New(0);
|
||||
ste->ste_children = PyList_New(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue