Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 2026: Note PY_VERSION_HEX changes needed for 3.YYYY #3995

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading