-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-107784 Document interpid C-API and new Unstable API for fetching __main__
of interpreter
#112548
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3341106
Document interpreter ID public API methods
tonybaloney ebd3bcb
Add documentation for interpreter ID objects
tonybaloney 0bdabbf
Move the docs to the init file
tonybaloney b9a8be3
Add PyUnstable_InterpreterState_GetMainModule
tonybaloney 8f9d7e1
Add blurb
tonybaloney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1225,6 +1225,12 @@ All of the following functions must be called after :c:func:`Py_Initialize`. | |||||
:c:func:`PyEval_SaveThread` is a higher-level function which is always | ||||||
available (even when threads have not been initialized). | ||||||
|
||||||
.. c:function:: PyObject* PyUnstable_InterpreterState_GetMainModule(PyInterpreterState *interp) | ||||||
|
||||||
Returns a :term:`strong reference` to the ``__main__`` module of the given interpreter *interp*. | ||||||
Fails with a :exc:`RuntimeError` if the interpreter is not initialized. | ||||||
|
||||||
.. versionadded:: 3.12 | ||||||
|
||||||
.. _sub-interpreter-support: | ||||||
|
||||||
|
@@ -1464,6 +1470,29 @@ function. You can create and destroy them using the following functions: | |||||
:c:func:`Py_FinalizeEx` will destroy all sub-interpreters that | ||||||
haven't been explicitly destroyed at that point. | ||||||
|
||||||
Interpreter ID Objects | ||||||
---------------------- | ||||||
|
||||||
A interpreter ID identifies a interpreter and may be used as an int. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hugovk suggested that you link to the class definition,
to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
.. versionadded:: 3.12 | ||||||
|
||||||
.. c:var:: PyTypeObject PyInterpreterID_Type | ||||||
|
||||||
This instance of :c:type:`PyTypeObject` represents the Python interpreter ID type. | ||||||
|
||||||
.. c:function:: PyObject* PyInterpreterID_New(int64_t id) | ||||||
|
||||||
Returns a new interpreter ID object with the given *id*. | ||||||
|
||||||
.. c:function:: PyInterpreterState* PyInterpreterID_LookUp(PyObject *requested_id) | ||||||
|
||||||
Returns a :term:`borrowed reference` to the :c:type:`PyInterpreterState` interpreter state for the given interpreter ID object *requested_id*. | ||||||
Fails with :exc:`RuntimeError` if the interpreter is not found. | ||||||
|
||||||
.. c:function:: PyObject* PyInterpreterState_GetIDObject(PyInterpreterState *interp) | ||||||
|
||||||
Returns a new interpreter ID object for the given interpreter state *interp*. | ||||||
|
||||||
A Per-Interpreter GIL | ||||||
--------------------- | ||||||
|
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Documentation/2023-11-30-18-44-35.gh-issue-107784.5okblM.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Added documentation for the ``PyUnstable_InterpreterState_GetMainModule`` | ||
and ``PyInterpreterID`` C-API. Patch by Anthony Shaw. |
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.
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 giving this some attention so that we can get it merged soon.
This section looks good so far