API i wersjonowanie ABI¶
Build-time version constants¶
CPython exposes its version number in the following macros.
Note that these correspond to the version code is built with.
See Py_Version for the version used at run time.
Więcej informacji na temat stabilności API i ABI w różnych wersjach można znaleźć na stronie C API Stability.
-
PY_MAJOR_VERSION¶
3w3.4.1a2.
-
PY_MINOR_VERSION¶
4w3.4.1a2.
-
PY_MICRO_VERSION¶
1w3.4.1a2.
-
PY_RELEASE_LEVEL¶
aw3.4.1a2. Może to być0xAdla wersji alfa,0xBdla wersji beta,0xCdla wersji kandydującej do wydania lub0xFdla wersji finalnej.
-
PY_RELEASE_SERIAL¶
2w3.4.1a2. Zero dla ostatecznych wydań.
-
PY_VERSION_HEX¶
The Python version number encoded in a single integer. See
Py_PACK_FULL_VERSION()for the encoding details.Używaj to do porównań liczbowych, na przykład
#if PY_VERSION_HEX >= ....
Run-time version¶
-
const unsigned long Py_Version¶
- Część stabilnego ABI od wersji 3.11.
The Python runtime version number encoded in a single constant integer. See
Py_PACK_FULL_VERSION()for the encoding details. This contains the Python version used at run time.Używaj to do porównań liczbowych, na przykład
if (Py_Version >= ...).Dodane w wersji 3.11.
Bit-packing macros¶
-
uint32_t Py_PACK_FULL_VERSION(int major, int minor, int micro, int release_level, int release_serial)¶
- Część stabilnego ABI od wersji 3.14.
Return the given version, encoded as a single 32-bit integer with the following structure:
Argument
Liczba bitów
Bit mask
Bit shift
Example values
3.4.1a23.10.0major
8
0xFF00000024
0x030x03minor
8
0x00FF000016
0x040x0Amicro
8
0x0000FF008
0x010x00release_level
4
0x000000F04
0xA0xFrelease_serial
4
0x0000000F0
0x20x0Na przykład:
Wersja
Py_PACK_FULL_VERSIONargumentyZakodowana wersja
3.4.1a2(3, 4, 1, 0xA, 2)0x030401a23.10.0(3, 10, 0, 0xF, 0)0x030a00f0Out-of range bits in the arguments are ignored. That is, the macro can be defined as:
#ifndef Py_PACK_FULL_VERSION #define Py_PACK_FULL_VERSION(X, Y, Z, LEVEL, SERIAL) ( \ (((X) & 0xff) << 24) | \ (((Y) & 0xff) << 16) | \ (((Z) & 0xff) << 8) | \ (((LEVEL) & 0xf) << 4) | \ (((SERIAL) & 0xf) << 0)) #endif
Py_PACK_FULL_VERSIONis primarily a macro, intended for use in#ifdirectives, but it is also available as an exported function.Dodane w wersji 3.14.
-
uint32_t Py_PACK_VERSION(int major, int minor)¶
- Część stabilnego ABI od wersji 3.14.
Equivalent to
Py_PACK_FULL_VERSION(major, minor, 0, 0, 0). The result does not correspond to any Python release, but is useful in numeric comparisons.Dodane w wersji 3.14.