Title: Use shared helper function for faster index range checks · Issue #120176 · python/cpython · GitHub
Open Graph Title: Use shared helper function for faster index range checks · Issue #120176 · python/cpython
X Title: Use shared helper function for faster index range checks · Issue #120176 · python/cpython
Description: #9784 (discussed in #72583 and #67741) introduced a helper function to reduce the number of comparisons in list index range checks (see https://godbolt.org/z/jM8oexT1d). The same pattern can be applied in many other places in the code ba...
Open Graph Description: #9784 (discussed in #72583 and #67741) introduced a helper function to reduce the number of comparisons in list index range checks (see https://godbolt.org/z/jM8oexT1d). The same pattern can be app...
X Description: #9784 (discussed in #72583 and #67741) introduced a helper function to reduce the number of comparisons in list index range checks (see https://godbolt.org/z/jM8oexT1d). The same pattern can be app...
Opengraph URL: https://github.com/python/cpython/issues/120176
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use shared helper function for faster index range checks","articleBody":"#9784 (discussed in #72583 and #67741) introduced a helper function to reduce the number of comparisons in list index range checks (see https://godbolt.org/z/jM8oexT1d).\r\n\r\nThe same pattern can be applied in many other places in the code base like in `arraymodule.c`, `mmapmodule.c`, `bytearrayobject.c`, etc.\r\n\r\nI'd propose to extract this helper function into a header and start using it in more places for index range checks. [`internal/pycore_abstract.h`](https://github.com/python/cpython/blob/main/Include/internal/pycore_abstract.h) seems like it might be a decent place to put this helper in.\r\n\r\nI'm happy to make a PR if people think a micro optimisation like this justifies the code churn, but let me know if I'm missing something.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-120181\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/lgeiger","@type":"Person","name":"lgeiger"},"datePublished":"2024-06-06T19:32:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/120176/cpython/issues/120176"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d2f1430a-4063-b16c-e0bf-9aa660983977 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A27A:2A0D62:1814779:212582B:696AAC74 |
| html-safe-nonce | 5177d9b0b3d45a22eb8d4c4fcd67b9e9cf31fd18089edef0775bf25e1706b6b1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjdBOjJBMEQ2MjoxODE0Nzc5OjIxMjU4MkI6Njk2QUFDNzQiLCJ2aXNpdG9yX2lkIjoiNjY5MjI0MTU1MzU5OTY3MTQxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c2e50e4bb9736ec5495c9de301acec61b69e367a08521f5156be891680cdb03b |
| hovercard-subject-tag | issue:2339017172 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/cpython/120176/issue_layout |
| twitter:image | https://opengraph.githubassets.com/73c615ad6af95a975a48e08fab441f7abbaa33b7e85c6771fb79677b8f9c7b3f/python/cpython/issues/120176 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/73c615ad6af95a975a48e08fab441f7abbaa33b7e85c6771fb79677b8f9c7b3f/python/cpython/issues/120176 |
| og:image:alt | #9784 (discussed in #72583 and #67741) introduced a helper function to reduce the number of comparisons in list index range checks (see https://godbolt.org/z/jM8oexT1d). The same pattern can be app... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lgeiger |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3eaf9b8cf1badcd7041a8ad480b9d9b28bea0ef1cc821ca9ff20f2cc7f4fe4b9 |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | dd9a979046e6382bd084e2bd873bf65f797125ff |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width