Apia Bi Version
Apia Bi Version
**********************
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**.
See C API Stability for a discussion of API and ABI stability across
versions.
PY_MAJOR_VERSION
PY_MINOR_VERSION
PY_MICRO_VERSION
PY_RELEASE_LEVEL
The "a" in "3.4.1a2". This can be "0xA" for alpha, "0xB" for beta,
"0xC" for release candidate or "0xF" for final.
PY_RELEASE_SERIAL
PY_VERSION_HEX
Run-time version
================
Use this for numeric comparisons, for example, "if (Py_Version >=
...)".
+--------------------+---------+------------------+-------------+---------------
+--------------+
| Argument | No. of | Bit mask | Bit shift | Example values
|
| | bits | | |
|
| | | | +---------------
+--------------+
| | | | | "3.4.1a2"
| "3.10.0" |
| | | | |
| |
|====================|=========|==================|=============|
===============|==============|
| *major* | 8 | "0xFF000000" | 24 | "0x03"
| "0x03" |
+--------------------+---------+------------------+-------------+---------------
+--------------+
| *minor* | 8 | "0x00FF0000" | 16 | "0x04"
| "0x0A" |
+--------------------+---------+------------------+-------------+---------------
+--------------+
| *micro* | 8 | "0x0000FF00" | 8 | "0x01"
| "0x00" |
+--------------------+---------+------------------+-------------+---------------
+--------------+
| *release_level* | 4 | "0x000000F0" | 4 | "0xA"
| "0xF" |
+--------------------+---------+------------------+-------------+---------------
+--------------+
| *release_serial* | 4 | "0x0000000F" | 0 | "0x2"
| "0x0" |
+--------------------+---------+------------------+-------------+---------------
+--------------+
For example:
+---------------+--------------------------------------+-------------------+
| Version | "Py_PACK_FULL_VERSION" arguments | Encoded version |
|===============|======================================|===================|
| "3.4.1a2" | "(3, 4, 1, 0xA, 2)" | "0x030401a2" |
+---------------+--------------------------------------+-------------------+
| "3.10.0" | "(3, 10, 0, 0xF, 0)" | "0x030a00f0" |
+---------------+--------------------------------------+-------------------+
Out-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