Skip to content

Commit

Permalink
PEP 2026: Note PY_VERSION_HEX changes needed for 3.YYYY (#3995)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Sep 26, 2024
1 parent 9c9c5c3 commit 2a3dfe0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions peps/pep-2026.rst
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,24 @@ However, YY.MM versioning is rejected for many of the same reasons as YY.0 versi
For example, Python 3.2026 would be released in 2026.

It's clearer that the minor version is a year when using a four digits, and
avoids confusion with Ubuntu versions which use YY.MM. However, this is
rejected as changing from two to four digits would break more code than 3.YY versioning.
avoids confusion with Ubuntu versions which use YY.MM.

``PY_VERSION_HEX``
''''''''''''''''''

CPython's C API :external+python:c:macro:`PY_VERSION_HEX` macro currently uses
eight bits to encode the minor version, accommodating a maximum minor version of
255. To hold a four-digit year, it would need to be expanded to 11 bits to fit
2047 or rather 12 bits for 4095.

This looks feasible, as it's intended for numeric comparisons, such as
``#if PY_VERSION_HEX >= ...``. In the `top 8,000 PyPI projects
<https://dev.to/hugovk/how-to-search-5000-python-projects-31gk>`__
only one instance was found of bit shifting
(``hexversion >> 16 != PY_VERSION_HEX >> 16``).

However, 3.YYYY is rejected as changing from two to four digits would
nevertheless need more work and break more code than simpler 3.YY versioning.

Editions
--------
Expand Down

0 comments on commit 2a3dfe0

Please sign in to comment.