gh-149716: Document PySlot_DATA for Py_mod_gil and Py_mod_multiple_interpreters#150053
Conversation
…ple_interpreters Add short code examples mirroring the existing Py_mod_abi example, so it is clear which slot definition macro (PySlot_DATA, PySlot_INT64, or PySlot_UINT64) to use for these two slots.
Documentation build overview
123 files changed ·
|
| machinery defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``. | ||
|
|
||
| A suitable slot value can be defined using the :c:macro:`PySlot_DATA` macro, | ||
| as in: |
There was a problem hiding this comment.
PySlot_DATA is only for the new PySlot arrays; not for the older PyModuleDef_Slot (where every value is a pointer, hence the type).
I'd word it like this:
| as in: | |
| For historical reasons, the values are declared as pointers (``void *``). | |
| When using :c:type:`PySlot` arrays, use :c:macro:`PySlot_DATA` for | |
| :c:macro:`!Py_mod_multiple_interpreters`: |
| A suitable slot value can be defined using the :c:macro:`PySlot_DATA` macro, | ||
| as in: |
There was a problem hiding this comment.
| A suitable slot value can be defined using the :c:macro:`PySlot_DATA` macro, | |
| as in: | |
| For historical reasons, the values are declared as pointers (``void *``). | |
| When using :c:type:`PySlot` arrays, use :c:macro:`PySlot_DATA` for | |
| :c:macro:`!Py_mod_gil`: |
Clarify that PySlot_DATA applies to PySlot arrays and note the historical void* declaration of the slot values, per review.
|
Applied both, thanks. I left |
encukou
left a comment
There was a problem hiding this comment.
Thank you!
I left
Py_mod_abias is — its value is a real pointer, so thevoid *note doesn't fit there.
Perfect :)
|
Thanks @Taeknology for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
|
GH-151322 is a backport of this pull request to the 3.15 branch. |
Fixes #149716.
Summary
Adds short code examples to the documentation of two module slot IDs
(
Py_mod_gilsince 3.13,Py_mod_multiple_interpreterssince 3.12).The examples mirror the existing one under
Py_mod_abiand make itexplicit that
PySlot_DATA(notPySlot_INT64/PySlot_UINT64)is the correct slot-definition macro for these two slots, because
their values (
Py_MOD_GIL_*,Py_MOD_MULTIPLE_INTERPRETERS_*,Py_MOD_PER_INTERPRETER_GIL_SUPPORTED) are defined as(void *)Nin
Include/moduleobject.h, andPySlot_DATAcasts tovoid *(
Include/slots.h).Changes
Doc/c-api/module.rst: add aPySlot_DATA(...)code-block to eachof the two slot sections, in the same 4-part style (intro sentence +
.. code-block:: c+ 6-space code +.. versionadded::) as theexisting
Py_mod_abiexample.The
Py_mod_multiple_interpretersexample showsPy_MOD_PER_INTERPRETER_GIL_SUPPORTED(rather than the default_SUPPORTED) since that is the value extension authors most often needto set explicitly. Likewise the
Py_mod_gilexample showsPy_MOD_GIL_NOT_USED(rather than the default_USED).Notes
Misc/NEWS.dentry per thedevguide.
Py_mod_abibyte-for-byte (3-space bodyindentation, 6-space code indentation, identical directive order).