Skip to content

Commit 5982204

Browse files
committed
PEP 803: add paragraph about bindings generators
1 parent 0527f60 commit 5982204

1 file changed

Lines changed: 56 additions & 6 deletions

File tree

peps/pep-0803.rst

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
PEP: 803
22
Title: "abi3t": Stable ABI for Free-Threaded Builds
33
Author: Petr Viktorin <encukou@gmail.com>
4+
Author: Nathan Goldbaum <nathan.goldbaum@gmail.com>
45
Discussions-To: https://discuss.python.org/t/106181
56
Status: Draft
67
Type: Standards Track
@@ -50,6 +51,7 @@ for free-threading should be prepared and defined for Python 3.15”.
5051

5152
This PEP proposes the Stable ABI for free-threading.
5253

54+
5355
Background
5456
----------
5557

@@ -79,6 +81,7 @@ were a part of older versions.
7981
This PEP proposes additional API limitations, as required to be compatible
8082
with both GIL-enabled and free-threaded builds of CPython.
8183

84+
8285
Ecosystem maintainers want decreased maintenance burden
8386
-------------------------------------------------------
8487

@@ -88,6 +91,7 @@ wheels, maintainers are left with a choice between closely following CPython
8891
releases and producing wheels during CPython beta periods or dealing with
8992
inevitable user requests for support for new CPython versions.
9093

94+
9195
Cryptography
9296
^^^^^^^^^^^^
9397

@@ -109,15 +113,28 @@ on discourse for a free-threaded stable ABI:
109113
long as we have O(1) builds, that’s ok. What we can’t/won’t do is O(n)
110114
where we need new builds for every Python release.
111115

116+
When one of the PEP authors asked him in the ``#pyca`` Libera IRC channel, he
117+
said:
118+
119+
One other thing I'll note that's *really* valuable about ``abi3`` is that it
120+
means our old wheels keep working for new Python versions. If we have
121+
per-Python release wheels, we have to do a bunch of work at various points
122+
in the python release cycle (including potentially backport releases to add
123+
new wheels, if we're not otherwise planning a release at that time).
124+
125+
As maintainers, we *really* like to structure our work to avoid being "on
126+
the clock" like that.
127+
128+
112129
moocore
113130
^^^^^^^
114131

115-
The moocore project `ships seven abi3 wheels
116-
<https://pypi.org/project/moocore/0.2.0/#files>`_. It has a much smaller
117-
userbase than cryptography and has a smaller appetite for build complexity. When
118-
the topic of adding support for the free-threaded build `came up on the moocore
119-
issue tracker <https://github.com/multi-objective/moocore/issues/37>`_,
120-
maintainer Manuel López-Ibáñez let the person reporting the issue know that:
132+
The `moocore project ships <https://pypi.org/project/moocore/0.2.0/#files>`_
133+
seven ``abi3`` wheels. It has a much smaller userbase than cryptography and has
134+
a smaller appetite for build complexity. When the topic of adding support for
135+
the free-threaded build `came up on the moocore issue tracker
136+
<https://github.com/multi-objective/moocore/issues/37>`_, maintainer Manuel
137+
López-Ibáñez let the person reporting the issue know that:
121138

122139
The free-threading versions are still experimental so each new
123140
free-threading python version will need its own wheels.
@@ -149,6 +166,39 @@ maintainer bandwidth spectrum, but both would still really like to have a stable
149166
ABI on the free-threaded build they can use to ship wheels and reduce their
150167
maintenance burden.
151168

169+
170+
Bindings Generators
171+
-------------------
172+
173+
Both moocore and cryptography use bindings generators to interface with the C
174+
API. Cryptography uses PyO3 and CFFI while moocore uses only CFFI. Both CFFI and
175+
PyO3 already handle all the details of abstracting over the C API to enable
176+
different build configurations and there is no need to laboriously port
177+
extension types to use APIs that are only available on one build or another.
178+
179+
Using bindings generators will enable these projects to quickly adopt the new
180+
stable ABI. Initial testing using the experimental ``_Py_OPAQUE_PYOBJECT`` flag
181+
defined in CPython's ``main`` branch, indicates that PyO3, CFFI, and Cython will
182+
all work with PEP 803 using packaging tools that have been patched to account
183+
for an ``abi3.abi3t`` tag.
184+
185+
Cython maintainer David Woods `says
186+
<https://github.com/cython/cython/issues/7399#issuecomment-3947605797>`_:
187+
188+
Cython is doesn't have huge problems with the number of wheels we distribute
189+
because ultimately it works fine as pure-Python. We do distribute wheels for
190+
a few of the smaller platforms as Stable ABI wheels but that's more
191+
"dogfooding" than because we actually need to. So I'm adding this in
192+
anticipation that other people will find it useful rather than because I
193+
will.
194+
195+
I do remain slightly concerned that the performance trade-offs for this will
196+
turn out to be too much for many Cython users (it's possible that the
197+
trade-off may be different for other binding tools). That's not a huge
198+
disaster since we're not getting rid of the regular compilation mode so
199+
people are free to pick their own personal trade-offs.
200+
201+
152202
Rationale
153203
=========
154204

0 commit comments

Comments
 (0)