FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-107784 Document interpid C-API and new Unstable API for fetching `__main__` of interpreter by tonybaloney · Pull Request #112548 · python/cpython · GitHub

/ cpython Public
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
29 changes: 29 additions & 0 deletions Doc/c-api/init.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
Expand Up @@ -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:

Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm giving this some attention so that we can get it merged soon.
This section looks good so far

----------------------

A interpreter ID identifies a interpreter and may be used as an int.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@hugovk suggested that you link to the class definition,
changing

A interpreter ID identifies a interpreter and may be used as an int.

to

A interpreter ID identifies a interpreter and may be used as an :class:`int`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
A interpreter ID identifies a interpreter and may be used as an int.
A interpreter ID identifies a interpreter and may be used as an :class:`int`.


.. 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
---------------------
Expand Down
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.

Back | FazBrowse Home | New Git URL