@@ -25,19 +25,19 @@ are private API that can change without notice even in patch releases.
25
25
Stable Application Binary Interface
26
26
===================================
27
27
28
+ For simplicity, this document talks about *extensions *, but the Limited API
29
+ and Stable ABI work the same way for all uses of the API – for example,
30
+ embedding Python.
31
+
32
+ .. _limited-c-api :
33
+
34
+ Limited C API
35
+ -------------
36
+
28
37
Python 3.2 introduced the *Limited API *, a subset of Python's C API.
29
38
Extensions that only use the Limited API can be
30
39
compiled once and work with multiple versions of Python.
31
- Contents of the Limited API are :ref: `listed below <stable-abi-list >`.
32
-
33
- To enable this, Python provides a *Stable ABI *: a set of symbols that will
34
- remain compatible across Python 3.x versions. The Stable ABI contains symbols
35
- exposed in the Limited API, but also other ones – for example, functions
36
- necessary to support older versions of the Limited API.
37
-
38
- (For simplicity, this document talks about *extensions *, but the Limited API
39
- and Stable ABI work the same way for all uses of the API – for example,
40
- embedding Python.)
40
+ Contents of the Limited API are :ref: `listed below <limited-api-list >`.
41
41
42
42
.. c :macro :: Py_LIMITED_API
43
43
@@ -57,6 +57,19 @@ embedding Python.)
57
57
You can also define ``Py_LIMITED_API `` to ``3 ``. This works the same as
58
58
``0x03020000 `` (Python 3.2, the version that introduced Limited API).
59
59
60
+
61
+ .. _stable-abi :
62
+
63
+ Stable ABI
64
+ ----------
65
+
66
+ To enable this, Python provides a *Stable ABI *: a set of symbols that will
67
+ remain compatible across Python 3.x versions.
68
+
69
+ The Stable ABI contains symbols exposed in the :ref: `Limited API
70
+ <limited-c-api>`, but also other ones – for example, functions necessary to
71
+ support older versions of the Limited API.
72
+
60
73
On Windows, extensions that use the Stable ABI should be linked against
61
74
``python3.dll `` rather than a version-specific library such as
62
75
``python39.dll ``.
@@ -101,9 +114,9 @@ Limited API Caveats
101
114
-------------------
102
115
103
116
Note that compiling with ``Py_LIMITED_API `` is *not * a complete guarantee that
104
- code conforms to the Limited API or the Stable ABI. `` Py_LIMITED_API `` only
105
- covers definitions, but an API also includes other issues, such as expected
106
- semantics.
117
+ code conforms to the :ref: ` Limited API < limited-c-api >` or the :ref: ` Stable ABI
118
+ <stable-abi>`. `` Py_LIMITED_API `` only covers definitions, but an API also
119
+ includes other issues, such as expected semantics.
107
120
108
121
One issue that ``Py_LIMITED_API `` does not guard against is calling a function
109
122
with arguments that are invalid in a lower Python version.
@@ -136,9 +149,9 @@ Platform Considerations
136
149
=======================
137
150
138
151
ABI stability depends not only on Python, but also on the compiler used,
139
- lower-level libraries and compiler options. For the purposes of the Stable ABI,
140
- these details define a “platform”. They usually depend on the OS
141
- type and processor architecture
152
+ lower-level libraries and compiler options. For the purposes of
153
+ the :ref: ` Stable ABI < stable-abi >`, these details define a “platform”. They
154
+ usually depend on the OS type and processor architecture
142
155
143
156
It is the responsibility of each particular distributor of Python
144
157
to ensure that all Python versions on a particular platform are built
@@ -147,12 +160,12 @@ This is the case with Windows and macOS releases from ``python.org`` and many
147
160
third-party distributors.
148
161
149
162
150
- .. _ stable-abi -list :
163
+ .. _ limited-api -list :
151
164
152
165
Contents of Limited API
153
166
=======================
154
167
155
168
156
- Currently, the Limited API includes the following items:
169
+ Currently, the :ref: ` Limited API < limited-c-api >` includes the following items:
157
170
158
171
.. limited-api-list ::
0 commit comments