API and ABI Versioning¶
CPython exposes its version number in the following macros. Note that these correspond to the version code is built with, not necessarily the version used at run time.
See C API Stability for a discussion of API and ABI stability across versions.
3.4.1a2. This can be
0xCfor release candidate or
3.4.1a2. Zero for final releases.
The Python version number encoded in a single integer.
The underlying version information can be found by treating it as a 32 bit number in the following manner:
Bits (big endian order)
Use this for numeric comparisons, e.g.
#if PY_VERSION_HEX >= ....
This version is also available via the symbol
const unsigned long Py_Version¶
- Part of the Stable ABI since version 3.11.
The Python runtime version number encoded in a single constant integer, with the same format as the
PY_VERSION_HEXmacro. This contains the Python version used at run time.
3.11 sürümünde geldi.
All the given macros are defined in Include/patchlevel.h.