Skip to content

Conversation

@iritkatriel
Copy link
Member

@iritkatrieliritkatriel commented Jun 21, 2024

@iritkatrieliritkatriel added skip news interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jun 21, 2024
Copy link
Contributor

@mdboommdboom left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

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

To do this we'll need to either:
Move _PyInterpreterFrame to a public header
Move _PyGenObject_HEAD to a private header.

If you can avoid breaking the API, the second option is preferable.

@bedevere-app
Copy link

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

@iritkatriel
Copy link
MemberAuthor

To do this we'll need to either: Move _PyInterpreterFrame to a public header Move _PyGenObject_HEAD to a private header.

If you can avoid breaking the API, the second option is preferable.

PyGenObject is API, so I don't think the second option is possible.

@markshannon
Copy link
Member

markshannon commented Jun 21, 2024

Is the actual structure of PyGenObject part of the API, or just its existence?
All the API functions take PyGenObject *, so we can move the structure definition to an internal header and leave
typedef struct _PyGenObject PyGenObject; in the public header.

@iritkatriel
Copy link
MemberAuthor

I have made the requested changes; please review again.

@bedevere-app
Copy link

Thanks for making the requested changes!

@mdboom, @markshannon: please review the changes made to this pull request.

Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

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

Nice, this will definitely make things more maintainable.

It would be good to get rid of the _PyGenObject_HEAD macro, but that's for another PR.

@iritkatrieliritkatriel added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Jun 23, 2024
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit c9ed63f 🤖

If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Jun 23, 2024
@iritkatriel
Copy link
MemberAuthor

It would be good to get rid of the _PyGenObject_HEAD macro, but that's for another PR.

Do you know the history, why we have three structs with the same structure but different names?

@markshannon
Copy link
Member

It would be good to get rid of the _PyGenObject_HEAD macro, but that's for another PR.

Do you know the history, why we have three structs with the same structure but different names?

Probably to avoid copy and pasting the struct for the coroutine classes and keep PyGenObject unchanged.

@iritkatrieliritkatriel merged commit 65a12c5 into python:mainJun 24, 2024
"generator", /* tp_name */
offsetof(PyGenObject, gi_iframe) +
offsetof(_PyInterpreterFrame, localsplus), /* tp_basicsize */
sizeof(PyGenObject), /* tp_basicsize */
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be offsetof(PyGenObject, gi_frame.localsplus) otherwise we are overallocating one PyObject * slot.

Likewise for PyCoroObject and PyAsyncGenObject

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Let's try that: #120941

@iritkatriel
Copy link
MemberAuthor

Probably to avoid copy and pasting the struct for the coroutine classes and keep PyGenObject unchanged.

But PyGenObject , PyCoroObject and PyAsyncGenObject are the same thing. Why don't we have just one type for all of them?

@markshannon
Copy link
Member

They haven't always been the same 299483c

mrahtz pushed a commit to mrahtz/cpython that referenced this pull request Jun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
JukkaL pushed a commit to python/mypy that referenced this pull request Oct 14, 2024
Instead of copying the implementation of `_PyGen_GetCode` every time it changes in cpython, use the public `PyGen_GetCode` function. The current implementation would break for Python 3.14 as it has been changed upstream in python/cpython#120835.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generator frame type should not be PyObject*[]

4 participants

@iritkatriel@markshannon@bedevere-bot@mdboom