Skip to content

gh-146636: PEP 803: Reference documentation#148013

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

gh-146636: PEP 803: Reference documentation#148013
encukou wants to merge 8 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 +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?

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.

Yeah, not too sure about the rules here. What about "the Stable ABIs"?

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 way I wrote it still sounds best to me...

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?

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`.

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?

@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 ;-)

Copy link
Copy Markdown
Contributor

@ngoldbaum ngoldbaum left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together! I left a few comments inline, please take them or leave them as you see fit.

defined this way.

In the :ref:`Stable ABI <stable-abi>` for free-threaded builds (``abi3t``),
this struct is opaque, and unusable in practice.
Copy link
Copy Markdown
Contributor

@ngoldbaum ngoldbaum Apr 3, 2026

Choose a reason for hiding this comment

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

This is all covered above, but for people who land here with a direct link to this section, you could add a cross-reference suggesting the PyModExport API instead?

When using a build tool (for example, ``setuptools``), the tool is
generally responsible for setting macros and synchronizing them with
extension filenames and other metadata.
Prefer using the tool's options over defining the macros manually.
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.

Maybe setuptools is a poor example to use above then? Because setuptools expects users to set the build flags manually...

You could delete the "(For example, SetupTools)" above, or maybe refer to meson-python or scikit-build-core instead? These days that's what I recommend to people depending on if they already use CMake or not.


The goal for the Limited API is to allow everything that is possible with the
- define both :c:macro:`!Py_LIMITED_API` and :c:macro:`!Py_TARGET_ABI3T`, or
- define only :c:macro:`!Py_LIMITED_API` and build for free-threaded Python.
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.

Suggested change
- define only :c:macro:`!Py_LIMITED_API` and build for free-threaded Python.
- Define only :c:macro:`!Py_LIMITED_API` and define :c:macro:`!Py_GIL_DISABLED`.
This happens automatically with a free-threaded interpreter, except on Windows.

free-threading (``cp315t``) separately.

Stable ABI for Free-Threaded Builds should typically
be selected in a build tool (such as Setuptools, meson-python, Cython,
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.

Maybe split this between build backends and bindings generators? Both probably need configuration.

It's a little confusing to group Cython in with meson-python.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
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.

6 participants