Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Defer functions defined in nested classes in free-threaded builds #127274

Closed
@mpage

Description

@mpage

Feature or enhancement

Proposal:

We currently only defer functions that do not have theCO_NESTED flag set:

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp