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:
mpage 2024-12-19 13:03:14 -08:00 committed by GitHub
parent e163e8d4e1
commit 255762c09f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 37 additions and 14 deletions

View file

@ -1289,6 +1289,8 @@ compute_code_flags(compiler *c)
flags |= CO_VARKEYWORDS;
if (ste->ste_has_docstring)
flags |= CO_HAS_DOCSTRING;
if (ste->ste_method)
flags |= CO_METHOD;
}
if (ste->ste_coroutine && !ste->ste_generator) {