blob: d95536cf7710d9cb9c6aa32fa1c4fba76543c392 [file] [log] [blame]
Martin v. Löwisc06917b2012-06-22 12:49:08 +02001.. highlightlang:: c
2
3.. _stable:
4
5**********************************
6Stable Appliction Binary Interface
7**********************************
8
9Traditionally, the C API of Python will change with every release.
10Most changes will be source-compatible, typically by only adding API,
11rather than changing existing API or removing API (although some
12interfaces do get removed after being deprecated first).
13
14Unfortunately, the API compatibility does not extend to binary
15compatibility (the ABI). The reason is primarily the evolution of
16struct definitions, where addition of a new field, or changing
17the type of a field, might not break the API, but can break the ABI.
18As a consequence, extension modules need to be recompiled for
19every Python release (although an exception is possible on Unix
20when none of the affected interfaces are used). In addition, on
21Windows, extension modules link with a specific pythonXY.dll and
22need to be recompiled to link with a newer one.
23
24Since Python 3.2, a subset of the API has been declared to guarantee
25a stable ABI. Extension modules wishing to use this API need to define
26Py_LIMITED_API. A number of interpreter details then become hidden
27from the extension module; in return, a module is built that works
28on any 3.x version (x>=2) without recompilation. In some cases, the
29stable ABI needs to be extended with new functions. Extensions modules
30wishing to use these new APIs need to set Py_LIMITED_API to the
31PY_VERSION_HEX value of the minimum Python version they want to
32support (e.g. 0x03030000 for Python 3.3). Such modules will work
33on all subsequent Python releases, but fail to load (because of
34missing symbols) on the older releases.
35
36As of Python 3.2, the set of functions available to the limited API
37is documented in PEP 384.
38
39.. XXX copy exact list here? Into each functions definition?