Skip to content

Commit d1ffa35

Browse files
committed
docs: move binary extension API/ABI overview to general section
1 parent a3f515d commit d1ffa35

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

‎source/guides/packaging-binary-extensions.rst‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ zipfiles) often won't work for extension modules (as the dynamic loading
102102
mechanisms on most platforms can only load libraries from disk).
103103

104104

105+
How binary extension modules work
106+
---------------------------------
107+
108+
The C API (Application Programming Interface) is the source-level
109+
contract used when compiling code: it defines functions, types, constants,
110+
and how callers use them. The C ABI (Application Binary Interface) is the
111+
corresponding binary-level contract used by already-compiled code, including
112+
details such as exported symbols, calling conventions, and data layout.
113+
114+
CPython exposes a rich C API, but extensions built against the full API are
115+
normally tied to the CPython minor version and platform they were compiled
116+
for because the full ABI is not stable across minor releases. Extensions
117+
that only use CPython's Limited API can instead target the
118+
:ref:`Stable ABI <cpython-stable-abi>`, which allows a single ``abi3`` wheel
119+
to work across multiple Python 3 minor versions on the same platform.
120+
105121
Alternatives to handcoded accelerator modules
106122
---------------------------------------------
107123

@@ -147,22 +163,9 @@ also be considered:
147163
Alternatives to handcoded wrapper modules
148164
-----------------------------------------
149165

150-
The C API (Application Programming Interface) is the source-level
151-
contract used when compiling code: it defines functions, types, constants,
152-
and how callers use them. The C ABI (Application Binary Interface) is the
153-
corresponding binary-level contract used by already-compiled code, including
154-
details such as exported symbols, calling conventions, and data layout.
155-
156-
CPython exposes a rich C API, but extensions built against the full API are
157-
normally tied to the CPython minor version and platform they were compiled
158-
for because the full ABI is not stable across minor releases. Extensions
159-
that only use CPython's Limited API can instead target the
160-
:ref:`Stable ABI <cpython-stable-abi>`, which allows a single ``abi3`` wheel
161-
to work across multiple Python 3 minor versions on the same platform.
162-
163-
These interfaces make it possible for Python users to tap into native
164-
libraries. However, wrapping modules by hand is quite tedious, so a number
165-
of other alternative approaches should be considered.
166+
Binary extensions let Python programs use existing native libraries.
167+
However, maintaining handcoded wrapper modules is tedious, so alternative
168+
approaches should be considered.
166169

167170
The approaches described below don't simplify the distribution case at all,
168171
but they *can* significantly reduce the maintenance burden of keeping

0 commit comments

Comments
 (0)