Skip to content

gh-146636: PEP 803: Reference documentation#148013

Open
encukou wants to merge 7 commits intopython:mainfrom
encukou:803-docs
Open

gh-146636: PEP 803: Reference documentation#148013
encukou wants to merge 7 commits intopython:mainfrom
encukou:803-docs

Conversation

@encukou
Copy link
Copy Markdown
Member

@encukou encukou commented Apr 2, 2026

Copy link
Copy Markdown
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

Congrats on the PEP acceptance :)

Mostly editorial comments from me. The content generally looks good.

Comment on lines +688 to +691
In the :ref:`Stable ABI <stable-abi>` for Free-Threaded Builds (``abi3t``),
this struct is opaque, and unusable in practice.
The struct, including all members, is part of Stable ABI for
non-free-threaded builds (``abi3``).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is "Free-Threaded Builds" in title case, but then "non-free-threaded builds" isn't?


.. c:macro:: Py_LIMITED_API
- ``abi3``, introduced in Pyton 3.2, is compatible with
**non**-:term:`free threaded <free-threaded build>` builds of CPython.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nitpicky, but I believe "free threaded" needs a dash here. In the original issue where we added the "free-threaded build" term (#144277), we determined that no dash was correct only when "free threaded" was a noun.

Comment on lines +221 to +223
Note that compiling for Stable ABI is *not* a complete guarantee that code will
be compatible with the expected Python versions.
Stable ABI prevents *ABI* issues, like linker errors due to missing
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we need to precede "Stable ABI" with "the"?

Suggested change
Note that compiling for Stable ABI is *not* a complete guarantee that code will
be compatible with the expected Python versions.
Stable ABI prevents *ABI* issues, like linker errors due to missing
Note that compiling for the Stable ABI is *not* a complete guarantee that code will
be compatible with the expected Python versions.
The Stable ABI prevents *ABI* issues, like linker errors due to missing

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Even if there's two of them?

symbols or data corruption due to changes in structure layouts or function
signatures.
However, other changes in Python can change the *behavior* of extensions.
See Python's Backwards Compatibility Policy (:pep:`387`) for details.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This sentence confused me a little when I first read it. I had read it as "We might change the behavior of extensions -- go read our backward compatibility policy if you want to know what", but then we provide an example right after the reader was diverted. Could we move this sentence to after the following paragraph, or put it in a seealso note?

C extensions that target the :ref:`Stable ABI <stable-abi>` can now be
compiled for the new *Stable ABI for Free-Threaded Builds* (also known
as ``abi3t``), which makes them compatible with
:term:`free-threaded build <free-threaded build>` builds of CPython.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
:term:`free-threaded build <free-threaded build>` builds of CPython.
:term:`free-threaded <free-threaded build>` builds of CPython.

part of the instance struct; and
- Switching from a ``PyInit_`` function to a new export hook,
:c:func:`PyModExport_* <PyModExport_modulename>`, introduced for this
purpose in :pep:`903`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
purpose in :pep:`903`.
purpose in :pep:`803`.

:c:func:`PyModExport_* <PyModExport_modulename>`, introduced for this
purpose in :pep:`903`.

Note that Stable ABI does not offer all functionality CPython has to offer.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Note that Stable ABI does not offer all functionality CPython has to offer.
Note that the Stable ABI does not offer all the functionality that CPython has to offer.

Or if you don't like "the" before "Stable ABI":

Suggested change
Note that Stable ABI does not offer all functionality CPython has to offer.
Note that Stable ABI does not offer all the functionality that CPython has to offer.

Comment on lines +411 to +412
be selected in a build tool (such as Setuptools, ``meson-python``, Cython,
Scikit-build-core, Maturin, and similar).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it intentional that meson-python is the only package in a code block here?

be selected in a build tool (such as Setuptools, ``meson-python``, Cython,
Scikit-build-core, Maturin, and similar).
At the time of writing this entry, these tools did **not** support ``abi3t``.
If this is the case for "your" tool, compile for ``cp315t`` separately.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, why is "your" in quotes?

At the time of writing this entry, these tools did **not** support ``abi3t``.
If this is the case for "your" tool, compile for ``cp315t`` separately.
If not using a build tool -- or when writing such a tool -- you can select
``abi3t`` by setting the macro :c:macro:`!Py_TARGET_ABI3T` as discussed
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it'd be nice if the Py_TARGET_ABI3T were an actual link, because it's not linked anywhere else in this section.

Suggested change
``abi3t`` by setting the macro :c:macro:`!Py_TARGET_ABI3T` as discussed
``abi3t`` by setting the macro :c:macro:`Py_TARGET_ABI3T` as discussed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The link would send you to a stub that mainly links to the common information.
I want to send people directly there -- that's the link on the next line.

@StanFromIreland
Copy link
Copy Markdown
Member

The new check caught removals: https://github.com/python/cpython/actions/runs/23907059205/job/69719041532?pr=148013 (and on your PR out of everyone's ;-)

There are two Stable ABIs:

.. c:macro:: Py_LIMITED_API
- ``abi3``, introduced in Pyton 3.2, is compatible with
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
- ``abi3``, introduced in Pyton 3.2, is compatible with
- ``abi3``, introduced in Python 3.2, is compatible with


Define this macro before including ``Python.h`` to opt in to only use
the Limited API, and to select the Limited API version.
- ``abi3t``, introduced in Pyton 3.15, is compatible with
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
- ``abi3t``, introduced in Pyton 3.15, is compatible with
- ``abi3t``, introduced in Python 3.15, is compatible with

On some platforms, Python will look for and load shared library files named
with the ``abi3`` or ``abi3t`` tag (for example, ``mymodule.abi3.so``).
:term:`Free threaded <free-threaded build>` interpreters only recognize the
``abi3t`` tag, while non-free threaded ones will prefer ``abi3`` but fall back
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
``abi3t`` tag, while non-free threaded ones will prefer ``abi3`` but fall back
``abi3t`` tag, while non-free-threaded ones will prefer ``abi3`` but fall back

signatures.
However, other changes in Python can change the *behavior* of extensions.
See Python's Backwards Compatibility Policy (:pep:`387`) for details.
When using a build tool (for example, ``setuptools``), the tool is
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
When using a build tool (for example, ``setuptools``), the tool is
When using a build tool (for example, Setuptools), the tool is

Typically, you should choose a specific value rather than the version of
the Python headers you are compiling against.

The macro(s) must be defined before including ``Python.h``.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"(s)" is a bit awkward, prefer a generic singular or plural:

Suggested change
The macro(s) must be defined before including ``Python.h``.
The macros must be defined before including ``Python.h``.

.. c:macro:: Py_TARGET_ABI3T

Target ``abi3t``, that is,
:term:`free-threaded <free-threaded build>` builds of CPython.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
:term:`free-threaded <free-threaded build>` builds of CPython.
:term:`free-threaded builds <free-threaded build>` of CPython.


Limited API Scope and Performance
---------------------------------
On a a :term:`free-threaded build` -- that is, when
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
On a a :term:`free-threaded build` -- that is, when
On a :term:`free-threaded build` -- that is, when

C extensions that target the :ref:`Stable ABI <stable-abi>` can now be
compiled for the new *Stable ABI for Free-Threaded Builds* (also known
as ``abi3t``), which makes them compatible with
:term:`free-threaded <free-threaded build>` builds of CPython.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
:term:`free-threaded <free-threaded build>` builds of CPython.
:term:`free-threaded builds <free-threaded build>` of CPython.


Stable ABI for Free-Threaded Builds should typically
be selected in a build tool (such as Setuptools, meson-python, Cython,
Scikit-build-core, Maturin, and similar).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't really need "and similar" after "such as".

Suggested change
Scikit-build-core, Maturin, and similar).
scikit-build-core, Maturin).

Stable ABI for Free-Threaded Builds should typically
be selected in a build tool (such as Setuptools, meson-python, Cython,
Scikit-build-core, Maturin, and similar).
At the time of writing this entry, these tools did **not** support ``abi3t``.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
At the time of writing this entry, these tools did **not** support ``abi3t``.
At the time of writing, these tools did **not** support ``abi3t``.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants