@@ -20,9 +20,9 @@ but will need to be compiled separately for 3.9.x and 3.10.x.
20
20
21
21
There are two tiers of C API with different stability exepectations:
22
22
23
- - * Unstable API * , may change in minor versions without a deprecation period.
24
- It is marked by the ``PyUnstable `` prefix in names.
25
- - * Limited API * , is compatible across several minor releases.
23
+ - :ref: ` Unstable API < unstable-c-api >` , may change in minor versions without
24
+ a deprecation period. It is marked by the ``PyUnstable `` prefix in names.
25
+ - :ref: ` Limited API < limited-c-api >` , is compatible across several minor releases.
26
26
When :c:macro: `Py_LIMITED_API ` is defined, only this subset is exposed
27
27
from ``Python.h ``.
28
28
@@ -55,19 +55,15 @@ CPython development and spend extra effort adjusting to changes.
55
55
Stable Application Binary Interface
56
56
===================================
57
57
58
+ .. _limited-c-api :
59
+
60
+ Limited C API
61
+ -------------
62
+
58
63
Python 3.2 introduced the *Limited API *, a subset of Python's C API.
59
64
Extensions that only use the Limited API can be
60
65
compiled once and work with multiple versions of Python.
61
- Contents of the Limited API are :ref: `listed below <stable-abi-list >`.
62
-
63
- To enable this, Python provides a *Stable ABI *: a set of symbols that will
64
- remain compatible across Python 3.x versions. The Stable ABI contains symbols
65
- exposed in the Limited API, but also other ones – for example, functions
66
- necessary to support older versions of the Limited API.
67
-
68
- (For simplicity, this document talks about *extensions *, but the Limited API
69
- and Stable ABI work the same way for all uses of the API – for example,
70
- embedding Python.)
66
+ Contents of the Limited API are :ref: `listed below <limited-api-list >`.
71
67
72
68
.. c :macro :: Py_LIMITED_API
73
69
@@ -87,6 +83,23 @@ embedding Python.)
87
83
You can also define ``Py_LIMITED_API `` to ``3 ``. This works the same as
88
84
``0x03020000 `` (Python 3.2, the version that introduced Limited API).
89
85
86
+
87
+ .. _stable-abi :
88
+
89
+ Stable ABI
90
+ ----------
91
+
92
+ To enable this, Python provides a *Stable ABI *: a set of symbols that will
93
+ remain compatible across Python 3.x versions.
94
+
95
+ The Stable ABI contains symbols exposed in the :ref: `Limited API
96
+ <limited-c-api>`, but also other ones – for example, functions necessary to
97
+ support older versions of the Limited API.
98
+
99
+ (For simplicity, this document talks about *extensions *, but the Limited API
100
+ and Stable ABI work the same way for all uses of the API – for example,
101
+ embedding Python.)
102
+
90
103
On Windows, extensions that use the Stable ABI should be linked against
91
104
``python3.dll `` rather than a version-specific library such as
92
105
``python39.dll ``.
@@ -131,9 +144,9 @@ Limited API Caveats
131
144
-------------------
132
145
133
146
Note that compiling with ``Py_LIMITED_API `` is *not * a complete guarantee that
134
- code conforms to the Limited API or the Stable ABI. `` Py_LIMITED_API `` only
135
- covers definitions, but an API also includes other issues, such as expected
136
- semantics.
147
+ code conforms to the :ref: ` Limited API < limited-c-api >` or the :ref: ` Stable ABI
148
+ <stable-abi>`. `` Py_LIMITED_API `` only covers definitions, but an API also
149
+ includes other issues, such as expected semantics.
137
150
138
151
One issue that ``Py_LIMITED_API `` does not guard against is calling a function
139
152
with arguments that are invalid in a lower Python version.
@@ -166,9 +179,9 @@ Platform Considerations
166
179
=======================
167
180
168
181
ABI stability depends not only on Python, but also on the compiler used,
169
- lower-level libraries and compiler options. For the purposes of the Stable ABI,
170
- these details define a “platform”. They usually depend on the OS
171
- type and processor architecture
182
+ lower-level libraries and compiler options. For the purposes of
183
+ the :ref: ` Stable ABI < stable-abi >`, these details define a “platform”. They
184
+ usually depend on the OS type and processor architecture
172
185
173
186
It is the responsibility of each particular distributor of Python
174
187
to ensure that all Python versions on a particular platform are built
@@ -177,12 +190,12 @@ This is the case with Windows and macOS releases from ``python.org`` and many
177
190
third-party distributors.
178
191
179
192
180
- .. _ stable-abi -list :
193
+ .. _ limited-api -list :
181
194
182
195
Contents of Limited API
183
196
=======================
184
197
185
198
186
- Currently, the Limited API includes the following items:
199
+ Currently, the :ref: ` Limited API < limited-c-api >` includes the following items:
187
200
188
201
.. limited-api-list ::
0 commit comments