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 — bpo-44800: rename _PyInterpreterFrame to _Py_frame by ncoghlan · Pull Request #31987 · python/cpython

Conversation

@ncoghlan

@ncoghlan ncoghlan commented Mar 19, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor
  • rename _PyInterpreterFrame to _Py_frame to help indicate that _Py_frame
    is an implementation optimisation for frame objects rather than a distinct concept
  • remove f_ prefix from _Py_frame fields that currently have it so presence or
    absence of the prefix disambiguates PyFrameObject and _Py_frame pointers
    when reading code snippets without their type declarations in code diffs
  • rename f_frame to f_fdata to avoid the odd frame->f_frame construct
  • rename _f_frame_data to _f_owned_fdata to avoid confusion with f_fdata
  • convert a potentially confusing use of cframe as a variable name to just frame
  • add a block comment to pycore_frame.h covering the naming conventions

https://bugs.python.org/issue44800

Sorry, something went wrong.

Uh oh!

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

All reactions
ncoghlan added 9 commits March 19, 2022 18:49
@ncoghlan
bpo-44800: Rename _PyInterpreterFrame to _Py_frame
ee2b513
@ncoghlan
Rename fdata->f_func to fdata->func
5326da8
@ncoghlan
Rename fdata->f_globals to fdata->globals
c878951
@ncoghlan
Rename fdata->f_builtins to fdata->builtins
bcafd65
@ncoghlan
Rename fdata->f_locals to fdata->locals
c324b81
@ncoghlan
Rename fdata->f_code to fdata->code
c16b2c4
@ncoghlan
Rename fdata->f_lasti to fdata->lasti
d26dca8
@ncoghlan
Rename fdata->f_state to fdata->state
40156aa
@ncoghlan
Fix misleading use of 'cframe' name in typeobject.c
a47e554
@ncoghlan
ncoghlan requested review from 1st1, iritkatriel and markshannon as code owners March 19, 2022 11:21
@bedevere-bot bedevere-bot added the awaiting core review label Mar 19, 2022
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 19, 2022
ncoghlan added 3 commits March 19, 2022 21:26
@ncoghlan
f_frame is not public, don't mention in What's New
37b1447
@ncoghlan
Rename frame->f_frame to frame->f_fdata
75326d6
@ncoghlan
Rename frame->_f_frame_data to frame->_f_owned_fdata
612a8e9
@ncoghlan ncoghlan mentioned this pull request Mar 19, 2022
WIP bpo-44800: Rename _PyInterpreterFrame to _Py_framedata #27525
Closed
@ncoghlan
Add NEWS entry
11653cc
@ncoghlan

ncoghlan commented Mar 19, 2022

Copy link
Copy Markdown
Contributor Author

Significantly scaled back from the original proposal in #27525, as per the Discourse thread at https://discuss.python.org/t/proposal-rename-pyinterpreterframe-struct-as-py-framedata/14213

All reactions

Sorry, something went wrong.

Uh oh!

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

ncoghlan added 2 commits March 19, 2022 22:08
@ncoghlan
Fix another use of cframe in typeoject.c
2775bf1
@ncoghlan
ReST is not Markdown
d2bc844
vstinner
vstinner previously requested changes Mar 19, 2022
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'm not convinced by the value of this large rename changes. I renamed _PyInterpreterFrame and _PyCFrame just before Python 3.11 alpha6 release which moves the PyFrameObject structure to the pycore_frame.h internal header file. The plan is now to updated 3rd party code projects to make them compatible with these changes (compatible with Python 3.11 alpha6): https://bugs.python.org/issue46836#msg414283

If we change this internal C API once more time (Python 3.11 alpha7 or another release), it would require one more compatibility layer to the compatibility sandwich of projects like Cython, greenlet and gevent which currently require to access to these members until faster-cpython/ideas#309 is implemented.

IMO investing time on implementing faster-cpython/ideas#309 first would make more sense, since right now there are still too many 3rd party code which require to access PyFrameObject members.

Once 3rd party code will no longer consume this internal C API, we will have more freedom to change it without annoying users. As I wrote, core devs are directly impacted since these changes often break pyperformance: https://bugs.python.org/issue46836#msg414279

cc @markshannon @brandtbucher

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-bot bedevere-bot removed the awaiting core review label Mar 19, 2022
@bedevere-bot

bedevere-bot commented Mar 19, 2022

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot added the awaiting changes label Mar 19, 2022
@vstinner

vstinner commented Mar 19, 2022

Copy link
Copy Markdown
Member

I'm not saying that these changes should not be done. The current API can be enhanced as you do. The problem is really a practical problem impacting users right now.

All reactions

Sorry, something went wrong.

Uh oh!

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

@ncoghlan

ncoghlan commented Mar 19, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

@vstinner If you're willing to volunteer to sync the PEP 558 working branch with CPython's main branch for me without these changes being made first, then I'll drop the proposal.

I didn't file the issue out of idle whim, I filed it as a result of trying to do that merge and failing abjectly because I couldn't easily tell which conflicting snippets were using full frame objects and needed to add a level of indirection to get to the frame data object and which should now be using the lower level frame data struct and should hence change their type declarations.

I know this code pretty well (both the old and the new versions), so if I can't follow it well enough to merge it with other code, that doesn't bode well for future maintainability.

If you want to make the case that it's already too late to fix this and we're now stuck with it forever just because I broke my arm last November and didn't push the point until I'd recovered, then the Discourse thread is the place to do it: https://discuss.python.org/t/proposal-rename-pyinterpreterframe-struct-as-py-framedata/14213

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Mar 19, 2022

Copy link
Copy Markdown
Member

PEP 558 is still a draft, no? Is it important to have an up to date implementation? There is also PEP 667. What's the status of these PEPs?

it's already too late to fix this and we're now stuck with it forever

That's not what I wrote. Once Cython, greenlet and gevent will be able to use a sane public C API, changing PyFrameObject internals will impact less projects.

All reactions

Sorry, something went wrong.

Uh oh!

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

@ncoghlan

ncoghlan commented Mar 19, 2022

Copy link
Copy Markdown
Contributor Author

And as I wrote on Discourse, if we don't change this internal layout for 3.11, we won't be able to change it in the future due to the problems it would create for bqckports.

All reactions

Sorry, something went wrong.

Uh oh!

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

@ncoghlan

ncoghlan commented Mar 19, 2022

Copy link
Copy Markdown
Contributor Author

PEP 558 is supposed to be in 3.11. The 3 months lost to my broken arm means it is likely that it isn't going to make it, but the readability problem revealed by attempting a merge of that magnitude is a separate issue (hence why I filed it as one)

All reactions

Sorry, something went wrong.

Uh oh!

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

@ncoghlan

ncoghlan commented Mar 19, 2022

Copy link
Copy Markdown
Contributor Author

I realised there's a macro hack we can use to keep code written for 3.11a6 compiling until a proper frame stack access API is available (presumably before 3.11b1).

The old field and type names aren't used anywhere else, so the C preprocessor can be used to automatically translate them at compile time.

All reactions

Sorry, something went wrong.

Uh oh!

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

@ncoghlan
Compatibility workaround to match 3.11a6 API
b275999
@ncoghlan
ncoghlan dismissed vstinner’s stale review March 20, 2022 03:50

Added a workaround that keeps 3.11a6 API compatibility by default

@ncoghlan

ncoghlan commented Mar 20, 2022

Copy link
Copy Markdown
Contributor Author

Thanks to C11, we're able to use static_assert now, so I was not only able to add a workaround that keeps code written against the 3.11a6 API working, but also compile time checks that those aliases were in place.

Temporarily adding #define _PY_FRAME_API_DISABLE_INTERIM_COMPAT_3_11a6 to frameobject.c also confirmed that that declaration turns off the compatibility aliases as expected (although rather than the static_asserts failing as such, they just fail to compile due to the missing type and field names referenced).

All reactions

Sorry, something went wrong.

Uh oh!

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

@ncoghlan

ncoghlan commented Mar 21, 2022

Copy link
Copy Markdown
Contributor Author

I'm going to scale back the proposal again to just the struct rename (keeping the old name around as a compatibility alias until there's a proper public API), and documenting the 7 frame data struct fields that have the "f_" prefix.

All reactions

Sorry, something went wrong.

Uh oh!

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

@ncoghlan ncoghlan closed this Mar 21, 2022
@ncoghlan

ncoghlan commented Mar 21, 2022

Copy link
Copy Markdown
Contributor Author

Scaled back PR is at #32024

All reactions

Sorry, something went wrong.

Uh oh!

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

@ncoghlan ncoghlan mentioned this pull request Apr 16, 2022
Code readability: rename InterpreterFrame to _Py_framedata #88963
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner left review comments
@iritkatriel iritkatriel Awaiting requested review from iritkatriel
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@1st1 1st1 Awaiting requested review from 1st1

Uh oh!

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

Assignees

No one assigned

Labels

awaiting changes

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.

4 participants

@ncoghlan @bedevere-bot @vstinner @the-knights-who-say-ni
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.