API와 ABI 버전 붙이기

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.

PY_MAJOR_VERSION

3.4.1a23.

PY_MINOR_VERSION

3.4.1a24.

PY_MICRO_VERSION

3.4.1a21.

PY_RELEASE_LEVEL

3.4.1a2a. 알파는 0xA, 베타는 0xB, 배포 후보는 0xC, 최종은 0xF 가 될 수 있습니다.

PY_RELEASE_SERIAL

3.4.1a22. 최종 배포는 0.

PY_VERSION_HEX

단일 정수로 인코딩된 파이썬 버전 번호.

기본 버전 정보는 다음과 같은 방식으로 32비트 숫자로 처리하여 찾을 수 있습니다:

바이트

비트 (빅 엔디안 순서)

3.4.1a2 일 때의 값

1

1-8

PY_MAJOR_VERSION

0x03

2

9-16

PY_MINOR_VERSION

0x04

3

17-24

PY_MICRO_VERSION

0x01

4

25-28

PY_RELEASE_LEVEL

0xA

29-32

PY_RELEASE_SERIAL

0x2

따라서 3.4.1a2는 16진수 버전 0x030401a2이고 3.10.0은 16진수 버전 0x030a00f0입니다.

Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ....

This version is also available via the symbol Py_Version.

const unsigned long Py_Version
Part of the 안정 ABI 버전 3.11 이후로.

The Python runtime version number encoded in a single constant integer, with the same format as the PY_VERSION_HEX macro. This contains the Python version used at run time.

Added in version 3.11.

모든 주어진 매크로는 Include/patchlevel.h에 정의됩니다.