Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
Feature or enhancement
Proposal:
We currently only defer functions that do not have theCO_NESTED flag set:
Lines 213 to 218 in26ff32b
| if ((code_obj->co_flags&CO_NESTED)==0) { | |
| // Use deferred reference counting for top-level functions, but not | |
| // nested functions because they are more likely to capture variables, | |
| // which makes prompt deallocation more important. | |
| _PyObject_SetDeferredRefcount((PyObject*)op); | |
| } |
This also excludes functions defined on nested classes. In the example below, theFoo.__init__ function will not use deferred reference counting because the__init__ method's code object has theCO_NESTED flag set.
deffunc():classFoo:def__init__(self):pass
We would like to relax the restriction onCO_NESTED to allow functions that are defined on nested classes to use deferred reference counting.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response