Title: bpo-46055: Streamline inner loop for right shifts by mdickinson · Pull Request #30243 · python/cpython · GitHub
Open Graph Title: bpo-46055: Streamline inner loop for right shifts by mdickinson · Pull Request #30243 · python/cpython
X Title: bpo-46055: Streamline inner loop for right shifts by mdickinson · Pull Request #30243 · python/cpython
Description: While reviewing #30044, I noticed that the inner loop for the right shift operation could be more efficient. Here's a PR that streamlines that loop. The main changes are: remove an unnecessary extra masking operation (& lomask), and replace & himask with & PyLong_MASK rewrite the loop to remove multiple accesses to the digits of a and z remove an inner branch On my machine (macOS 10.14.6 / Intel MacBook Pro), in informal timings I get approximately a 35% speedup for a shift of the form huge >> small. Some sample timings: On main (commit cf15419): lovelace:cpython mdickinson$ ./python.exe -m timeit -s "a, b = 7**100000, 53" "a >> b" 20000 loops, best of 5: 11.5 usec per loop On this branch (commit 056495d): lovelace:cpython mdickinson$ ./python.exe -m timeit -s "a, b = 7**100000, 53" "a >> b" 50000 loops, best of 5: 8.51 usec per loop Small shift operations are not significantly affected. More sample timings - on master: lovelace:cpython mdickinson$ ./python.exe -m timeit -s "a, b = 7**10, 53" "a >> b" 10000000 loops, best of 5: 23.3 nsec per loop On this branch: lovelace:cpython mdickinson$ ./python.exe -m timeit -s "a, b = 7**10, 53" "a >> b" 10000000 loops, best of 5: 24 nsec per loop (but a second run on this branch gave 22.9 nsec per loop, so any difference is being lost in the variation between runs) https://bugs.python.org/issue46055
Open Graph Description: While reviewing #30044, I noticed that the inner loop for the right shift operation could be more efficient. Here's a PR that streamlines that loop. The main changes are: remove an unnecessary...
X Description: While reviewing #30044, I noticed that the inner loop for the right shift operation could be more efficient. Here's a PR that streamlines that loop. The main changes are: remove an unneces...
Opengraph URL: https://github.com/python/cpython/pull/30243
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:b2fd5745-b6e8-f6be-6081-58fe9a10d328 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | A2B4:2F30AE:355313:4696F5:696B3C7D |
| html-safe-nonce | d690c75309780f7d85b645f049a49b4f2784d7116ccce8c4c996de0e60be4847 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMkI0OjJGMzBBRTozNTUzMTM6NDY5NkY1OjY5NkIzQzdEIiwidmlzaXRvcl9pZCI6IjYyNzA5NDY4NzE1MDUyNzE5MzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 124e30497f2c3a36b29ba9d2d9dc6b49cebc786c2bb400d3aa92f42fdf87e869 |
| hovercard-subject-tag | pull_request:809205369 |
| 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/30243/checks |
| twitter:image | https://avatars.githubusercontent.com/u/662003?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/662003?s=400&v=4 |
| og:image:alt | While reviewing #30044, I noticed that the inner loop for the right shift operation could be more efficient. Here's a PR that streamlines that loop. The main changes are: remove an unnecessary... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width