Title: Speed up bytes.hex() and related pystrhex.c users using SIMD · Issue #144015 · python/cpython · GitHub
Open Graph Title: Speed up bytes.hex() and related pystrhex.c users using SIMD · Issue #144015 · python/cpython
X Title: Speed up bytes.hex() and related pystrhex.c users using SIMD · Issue #144015 · python/cpython
Description: Feature or enhancement Proposal: We consolidated much of our bytes -> hexadecimal string code into one place as Python/pystrhex.c a while back. It is still written using a traditional scalar iterate over bytes and convert their nibbles l...
Open Graph Description: Feature or enhancement Proposal: We consolidated much of our bytes -> hexadecimal string code into one place as Python/pystrhex.c a while back. It is still written using a traditional scalar iterat...
X Description: Feature or enhancement Proposal: We consolidated much of our bytes -> hexadecimal string code into one place as Python/pystrhex.c a while back. It is still written using a traditional scalar ite...
Opengraph URL: https://github.com/python/cpython/issues/144015
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Speed up bytes.hex() and related pystrhex.c users using SIMD","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nWe consolidated much of our bytes -\u003e hexadecimal string code into one place as Python/pystrhex.c a while back. It is still written using a traditional scalar iterate over bytes and convert their nibbles logic as i snatural. Now that it's all in one place, we can do better.\n\nx86_64 and arm64 (aarch64) are both guaranteed to have SSE2 and NEON respectively which can handle processing 16 bytes at once. Modern compilers, starting with clang eons ago, and more recently with gcc 12 (2022) abstract the operation we need to do into a nice function so we do not even need to directly write the CPU specific code for this use case. Maintainability win!\n\nWill it be worthwhile? It turns out the answer is yes (see PR). It is minor on something as lowly as a baseline minimum md5.hexdigest() (16-bytes) but is clear on larger data such as sha256.hexdigest() and sha512.hexdigest(). At those sizes it is common to see 1.5-3x faster hex conversion. Realistically I doubt many applications are doing conversions from binary data into hex larger than those quite common practical use cases, but it can be \u003e10x faster if so (as measured at 4K).\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-143991\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/gpshead","@type":"Person","name":"gpshead"},"datePublished":"2026-01-18T18:58:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/144015/cpython/issues/144015"}
| 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:13dd2695-7b0b-8b22-3d76-99d0db6191fc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 960C:3C62DE:70CFA8B:950BEEB:696DE02F |
| html-safe-nonce | cbbc6bcbdab3d8c9f288793ae354c7a37222ce966e877d4c619db86ad7595962 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjBDOjNDNjJERTo3MENGQThCOjk1MEJFRUI6Njk2REUwMkYiLCJ2aXNpdG9yX2lkIjoiNDA5OTk3NTIzNzA2OTU2MTkwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1ddd2795af79abdfdf85a4297333d6c371c215432ac25fd061d3a2dd20d25e83 |
| hovercard-subject-tag | issue:3827160096 |
| 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/144015/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5034369084d23f6fe69a1db0ac3c423c51817edc67b4515122ef87e190929d45/python/cpython/issues/144015 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5034369084d23f6fe69a1db0ac3c423c51817edc67b4515122ef87e190929d45/python/cpython/issues/144015 |
| og:image:alt | Feature or enhancement Proposal: We consolidated much of our bytes -> hexadecimal string code into one place as Python/pystrhex.c a while back. It is still written using a traditional scalar iterat... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gpshead |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4922b452d03cd8dbce479d866a11bc25b59ef6ee2da23aa9b0ddefa6bd4d0064 |
| 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 | 7e5ae23c70136152637ceee8d6faceb35596ec46 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width