Title: Docs: Use PY_VERSION_HEX for version comparison by hugovk · Pull Request #100179 · python/cpython · GitHub
Open Graph Title: Docs: Use PY_VERSION_HEX for version comparison by hugovk · Pull Request #100179 · python/cpython
X Title: Docs: Use PY_VERSION_HEX for version comparison by hugovk · Pull Request #100179 · python/cpython
Description: PY_VERSION_HEX should be used when comparing version numbers, for example PY_VERSION_HEX >= 0x03080000. Avoid PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8 because that is true for 3.8-3.12, but also for 4.8-4.12 and so on. This is already warned in patchlevel.h where PY_VERSION_HEX is defined: cpython/Include/patchlevel.h Lines 29 to 35 in 2e279e8 /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ #define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \ (PY_MINOR_VERSION << 16) | \ (PY_MICRO_VERSION << 8) | \ (PY_RELEASE_LEVEL << 4) | \ (PY_RELEASE_SERIAL << 0)) It's a bit hidden there, let's hoist it into docs in apiabiversion.rst for visibilty. Preview https://deploy-preview-100179--python-cpython-preview.netlify.app/c-api/apiabiversion.html#c.PY_VERSION_HEX https://deploy-preview-100179--python-cpython-preview.netlify.app/whatsnew/3.11.html#whatsnew311-c-api-porting
Open Graph Description: PY_VERSION_HEX should be used when comparing version numbers, for example PY_VERSION_HEX >= 0x03080000. Avoid PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8 because that is true fo...
X Description: PY_VERSION_HEX should be used when comparing version numbers, for example PY_VERSION_HEX >= 0x03080000. Avoid PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8 bec...
Opengraph URL: https://github.com/python/cpython/pull/100179
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:f5bd3a2c-8702-b7ae-e82d-e85761e82227 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | A388:7B048:8AD20:BDF21:69695385 |
| html-safe-nonce | 6870d4eca2038aae954974ee62f7f830511424ce1ffb07aa0cbaabaf18382f12 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzg4OjdCMDQ4OjhBRDIwOkJERjIxOjY5Njk1Mzg1IiwidmlzaXRvcl9pZCI6IjYwNzcxMjUwNjQ4NDAwMDg1ODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 68d35864479ebddd062ecff924cfc3ff5a5d018ee2637a23e82f8bf3c1bf7700 |
| hovercard-subject-tag | pull_request:1159549836 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/100179/checks |
| twitter:image | https://avatars.githubusercontent.com/u/1324225?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1324225?s=400&v=4 |
| og:image:alt | PY_VERSION_HEX should be used when comparing version numbers, for example PY_VERSION_HEX >= 0x03080000. Avoid PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8 because that is true fo... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d69ac0477df0f87da03b8b06cebd187012d7a930 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width