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/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:b6e924e6-54e1-56ac-4699-3faa417ce760 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9586:320F8E:AE05DB:EFAB7A:696A8804 |
| html-safe-nonce | fdf50c11bc5ae6f9ef486826b245d24d938540c6de54f80044afd755f7232008 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTg2OjMyMEY4RTpBRTA1REI6RUZBQjdBOjY5NkE4ODA0IiwidmlzaXRvcl9pZCI6Ijg4OTAyMDkwMDMxMTEwOTAxODAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9e90ac391b0314846b6557de31b105fdf0ae1d4c2312cbe50dca362447cb2560 |
| hovercard-subject-tag | pull_request:809205369 |
| 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/30243/files |
| 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 | d2aa6dedd7d97fa651b17c40401f2605f309df5ca5fb659bf0554cf34f1de825 |
| 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 |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c1dbca8981c5e3d6a69bce2f1d289e732b86241d |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width