Visitar URL original
Allow the `f_func` field of the `_PyInterpreterFrame` struct to be any object (and rename it) · Issue #96237 · python/cpython · GitHub
Skip to content

Allow the f_func field of the _PyInterpreterFrame struct to be any object (and rename it) #96237

Description

@markshannon

In order to better support shim frames, trampolines, Cython frames and other such bits and pieces, we need to relax the requirement that the f_func field is a function.
The only reason for it to be a function is that it needs to hold a strong reference to builtins and globals, as the frame only has a borrowed reference to those. Any object with those references will do.
In fact, for code that has no builtins or globals (many shims and trampolines) there is no need for those references and f_func could even be None.

Activity

  1. iritkatriel commented on Aug 24, 2022

    @iritkatriel
    Member

    Does it really need to allow any object? Could you instead define a small number of object types that it can be?

  2. markshannon commented on Aug 24, 2022

    @markshannon
    MemberAuthor

    I don't see any advantage to restricting the possible types. Allowing any object is no worse for any code reading from f_funcobj and more flexible for anything storing to it.

    Given the values of f_globals and f_builtins can no longer be trusted, I think I'll make them void * just to make it clear that if you didn't set them, then you can't trust them.

  3. added a commit that references this issue on Aug 25, 2022
  4. carljm commented on Feb 14, 2023

    @carljm
    Member

    Currently whatever is in f_funcobj also needs to have a func_closure. #101310 demonstrates one way to remove this requirement.

  5. carljm commented on Feb 14, 2023

    @carljm
    Member

    Should this issue be closed, given the attached PR was merged? Or is there more planned here?

  6. markshannon commented on Apr 3, 2023

    @markshannon
    MemberAuthor

    Superseded by #100987

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usage

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions