GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-141518: Add PyUnstable_InterpreterFrame_GetFrameObject() function by vstinner · Pull Request #141950 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Nov 25, 2025 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Add also PyUnstable_InterpreterFrame type.

  • Issue: [C API] Promote PEP 523 functions to public functions: add PyUnstable_InterpreterState_SetEvalFrameFunc() #141518

📚 Documentation preview 📚: https://cpython-previews--141950.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
pythongh-141518: Add PyUnstable_InterpreterFrame_GetFrameObject() fun…
58ac314
…ction

Add also PyUnstable_InterpreterFrame type.
@vstinner
vstinner requested review from AA-Turner, ZeroIntensity, ericsnowcurrently and markshannon as code owners November 25, 2025 15:40
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 25, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Nov 25, 2025
[C API] Promote PEP 523 functions to public functions: add PyUnstable_InterpreterState_SetEvalFrameFunc() #141518
Closed
@vstinner vstinner mentioned this pull request Nov 25, 2025
gh-141518: Add PyUnstable_InterpreterState_SetEvalFrameFunc() #141665
Closed
@vstinner

vstinner commented Nov 25, 2025

Copy link
Copy Markdown
Member Author

See #141665 (review) for the rationale on adding this function.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner added 2 commits November 25, 2025 17:24
@vstinner
Update documentation
3e6cc65
@vstinner
Fix reference in the documentation
d02c524
emmatyping
emmatyping reviewed Nov 26, 2025
View reviewed changes
Comment thread Doc/c-api/frame.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Enhance PyUnstable_InterpreterFrame doc
1041017
efimov-mikhail
efimov-mikhail reviewed Nov 28, 2025
View reviewed changes
Comment thread Doc/c-api/frame.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Include/cpython/pyframe.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/C_API/2025-11-25-16-35-36.gh-issue-141518.gEueQd.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Objects/frameobject.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

vstinner and others added 2 commits November 28, 2025 12:30
@vstinner @efimov-mikhail
Update Doc/c-api/frame.rst
1d8d314
Co-authored-by: Mikhail Efimov <[email protected]>
@vstinner
Address review
559096c
efimov-mikhail
efimov-mikhail approved these changes Nov 28, 2025
View reviewed changes
@markshannon

markshannon commented Dec 1, 2025

Copy link
Copy Markdown
Member

I don't think we should add PyUnstable_InterpreterFrame_GetFrameObject().

If someone wants a frame object, they can get it directly with sys._getframe() or the C API equivalent.
The whole point of using _PyInterpreterFrame is to avoid the overhead of creating a frame object.
Also, PyUnstable_InterpreterFrame_GetFrameObject() is not a simpler getter, but will often have to create the frame object.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Dec 1, 2025

Copy link
Copy Markdown
Member Author

Well, @encukou requested such API for PyUnstable_InterpreterState_SetEvalFrameFunc(): #141665 (review)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner mentioned this pull request Dec 1, 2025
Add PyUnstable_InterpreterState_SetEvalFrameFunc() function capi-workgroup/decisions#89
Closed
@encukou

encukou commented Dec 2, 2025

Copy link
Copy Markdown
Member

sys._getframe() won't work in a frame evaluation function -- until the new frame is set up, it returns the previous one.

Should it be PyUnstable_InterpreterFrame_AsFrameObject?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Dec 2, 2025

Copy link
Copy Markdown
Member

In a frame evaluation function, you don't want the frame object. It is just a bulkier, slower version of the frame you already have. The frame object contains no additional information, just a pointer back to the internal frame.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Dec 3, 2025

Copy link
Copy Markdown
Member Author

In a frame evaluation function, you don't want the frame object

Yeah, you should use the internal C API to access the interpreter frame: pycore_interpframe.h provides many functions, such as:

  • _PyFrame_GetCode()
  • _PyFrame_GetBytecode()
  • _PyFrame_GetFunction()
  • _PyFrame_IsIncomplete()
  • etc.

I know that it's kind of unusual to have a public function to set a frame evalution function, but need the internal C API to implement it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner closed this Feb 10, 2026
@vstinner
vstinner deleted the interpframe branch February 10, 2026 17:41
@vstinner

vstinner commented Feb 10, 2026

Copy link
Copy Markdown
Member Author

The C API Working Group decided to not add a public function for this feature, but keep the _Py name instead: capi-workgroup/decisions#89.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@emmatyping emmatyping emmatyping left review comments
@efimov-mikhail efimov-mikhail efimov-mikhail approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@ZeroIntensity ZeroIntensity Awaiting requested review from ZeroIntensity ZeroIntensity is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@vstinner @markshannon @encukou @efimov-mikhail @emmatyping
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.