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/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:761aabfc-d012-d9ba-f286-21e1dd34913b |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C0CE:2ACFDC:BA40EB:FA0AA9:69699868 |
| html-safe-nonce | 68e4cfe4e7f7fb84f262ba584da97336fb771ea734a8ac78b6d65d30cce78a5f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMENFOjJBQ0ZEQzpCQTQwRUI6RkEwQUE5OjY5Njk5ODY4IiwidmlzaXRvcl9pZCI6IjYxNTU3NTE1OTY2MDg4MjEzNTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 314abdd8da7ba237aeead9482402ba6b0355f5f33331bc3f8772025a89d9dec0 |
| hovercard-subject-tag | pull_request:1159549836 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/files |
| 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 | 3542e147982176a7ebaa23dfb559c8af16f721c03ec560c68c56b64a0f35e751 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | af80af7cc9e3de9c336f18b208a600950a3c187c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width