Skip to content

Commit 3098dc0

Browse files
authored
Merge pull request #2145 from harshitethic/docs-api-abi-47
Explain the difference between C API and ABI
2 parents 1f4f317 + 971bf2f commit 3098dc0

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

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

Lines changed: 19 additions & 5 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 feature release and platform they were compiled
116+
against because the full ABI is not stable across feature releases.
117+
Extensions 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 feature releases on the same platform.
120+
105121
Alternatives to handcoded accelerator modules
106122
---------------------------------------------
107123

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

150-
The C ABI (Application Binary Interface) is a common standard for sharing
151-
functionality between multiple applications. One of the strengths of the
152-
CPython C API (Application Programming Interface) is allowing Python users
153-
to tap into that functionality. However, wrapping modules by hand is quite
154-
tedious, so a number 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.
155169

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

0 commit comments

Comments
 (0)