-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
Added some more info on PyModule_GetState doc. #138823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
Maybe like this?
Doc/c-api/module.rst
Outdated
allocated at module creation time, or ``NULL``. See | ||
:c:member:`PyModuleDef.m_size`. | ||
The module’s state can be stored in per‑module memory, which is obtained by calling this function. | ||
This makes modules safe to use with sub‑interpreters. |
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.
This makes modules safe to use with sub‑interpreters. |
This is too specific.
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.
But isn't it the most useful feature of this function? Otherwise it doesn't makes sense to store per-module state.
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.
Maybe instead link to the PEP?
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.
Added PEP link.
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.
Sorry, but I disagree. PEPs shouldn't be used as documentation, because they're solely historical documents and don't receive updates when we change things. I think we should keep the "This makes modules safe to use with sub‑interpreters" sentence, because yes -- that's what this function is for.
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.
I suggest leave things as is. There's no issue.
Maybe just add PEP link, indeed.
bf028b2
to
c65633d
Compare
@skirpichev, @sobolevn. Intead of all the changes added link to the respective PEP. Can you please take a look once again? |
@@ -96,6 +96,7 @@ Module Objects | |||
allocated at module creation time, or ``NULL``. See | |||
:c:member:`PyModuleDef.m_size`. | |||
|
|||
See :PEP:`489` for more details. |
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.
See :PEP:`489` for more details. | |
See :pep:`489` for more details. |
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.
I'm still not sure if that's helpful. PEP 489 introduces a lot of API, why mention it just there? And also PyModule_GetState() was added by a different PEP, IIRIC.
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.
Please don't solely link to the PEP. I think the original sentence ("This makes modules safe to use with sub‑interpreters") was fine.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
This PR adds more information on how to use the
PyModule_GetState
function, clarifying what argument should be passed.At first glance, people might incorrectly think they need to pass a pointer to a state struct that the function will populate, but that is not the case.
📚 Documentation preview 📚: https://cpython-previews--138823.org.readthedocs.build/