René's URL Explorer Experiment


Title: gh-146192: Add base32 support to binascii by kangtastic · Pull Request #146193 · python/cpython · GitHub

Open Graph Title: gh-146192: Add base32 support to binascii by kangtastic · Pull Request #146193 · python/cpython

X Title: gh-146192: Add base32 support to binascii by kangtastic · Pull Request #146193 · python/cpython

Description: Synopsis Add base32 encoder and decoder functions implemented in C to binascii and use them to greatly improve the performance and reduce the memory usage of the existing base32 codec functions in base64. No API or documentation changes are necessary with respect to any functions in base64, and all existing unit tests for those functions continue to pass without modification. Resolves: gh-146192 Discussion The base32-related functions in base64 are now wrappers for the new functions in binascii, as envisioned in the docs: The binascii module contains a number of methods to convert between binary and various ASCII-encoded binary representations. Normally, you will not use these functions directly but use wrapper modules like uu or base64 instead. The binascii module contains low-level functions written in C for greater speed that are used by the higher-level modules. Comments and questions are welcome. Benchmarks Benchmark script # bench_b32.py # Note: Can be EXTREMELY SLOW on unmodified mainline CPython. import base64 import sys import timeit import tracemalloc funcs = [(base64.b64encode, base64.b64decode), # sanity check/comparison (base64.b32encode, base64.b32decode), (base64.b32hexencode, base64.b32hexdecode)] def mb(n): return f"{n / 1024 / 1024:.3f}" def stats(func, data, t, m): name, n, bps = func.__qualname__, len(data), len(data) / t print(f"{name:<16}{n:<16}{t:<11.3f}{mb(bps):<13}{mb(m)}") if __name__ == "__main__": print(f"Python {sys.version}\n") print(f"function processed (b) time (s) avg (MB/s) mem (MB)\n") data = b"a" * int(sys.argv[1]) * 1024 * 1024 for fenc, fdec in funcs: tracemalloc.start() enc = fenc(data) menc = tracemalloc.get_traced_memory()[1] - len(enc) tracemalloc.stop() tenc = timeit.timeit("fenc(data)", number=1, globals=globals()) stats(fenc, data, tenc, menc) tracemalloc.start() dec = fenc(enc) mdec = tracemalloc.get_traced_memory()[1] - len(dec) tracemalloc.stop() tdec = timeit.timeit("fdec(enc)", number=1, globals=globals()) stats(fdec, enc, tdec, mdec) Unmodified mainline CPython $ ./python bench_b32.py 16 Python 3.15.0a7+ (heads/main:d357a7dbf38, Mar 19 2026, 23:22:25) [GCC 15.2.0] function processed (b) time (s) avg (MB/s) mem (MB) b64encode 16777216 0.015 1088.370 0.000 b64decode 22369624 0.017 1264.389 0.000 b32encode 16777216 2.308 6.933 17.382 b32decode 26843552 3.389 7.553 27.787 b32hexencode 16777216 2.338 6.843 17.379 b32hexdecode 26843552 3.388 7.557 27.787 With this PR $ ./python bench_b32.py 16 Python 3.15.0a7+ (heads/base32-accel:72fd0f0302a, Mar 20 2026, 00:04:23) [GCC 15.2.0] function processed (b) time (s) avg (MB/s) mem (MB) b64encode 16777216 0.015 1084.957 0.000 b64decode 22369624 0.016 1363.524 0.000 b32encode 16777216 0.017 967.528 0.000 b32decode 26843552 0.016 1581.002 0.000 b32hexencode 16777216 0.016 995.277 0.000 b32hexdecode 26843552 0.016 1588.353 0.000 Encoding performance is improved by ~150x, decoding performance is improved by ~200x, and no auxiliary memory is used. 📚 Documentation preview 📚: https://cpython-previews--146193.org.readthedocs.build/

Open Graph Description: Synopsis Add base32 encoder and decoder functions implemented in C to binascii and use them to greatly improve the performance and reduce the memory usage of the existing base32 codec functions in ...

X Description: Synopsis Add base32 encoder and decoder functions implemented in C to binascii and use them to greatly improve the performance and reduce the memory usage of the existing base32 codec functions in ...

Opengraph URL: https://github.com/python/cpython/pull/146193

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:c3fd8c9b-6c7f-a313-f428-a6e1208c69b5
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAED8:3DE393:368FF69:4ABB6E2:6A508B9F
html-safe-nonce7f74b1af50c5bbe3ce9ff984ac4e19e8359c53ad0693ac043f9316e40c3ed321
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRUQ4OjNERTM5MzozNjhGRjY5OjRBQkI2RTI6NkE1MDhCOUYiLCJ2aXNpdG9yX2lkIjoiMTQwNDc5NDcyMjM4ODU3NzE4MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac72963bf8133d0317d43c7cc1dc08b0f05018986656f59e7cdea9a03922d6fdc7
hovercard-subject-tagpull_request:3423832139
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/146193/files
twitter:imagehttps://avatars.githubusercontent.com/u/942136?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/942136?s=400&v=4
og:image:altSynopsis Add base32 encoder and decoder functions implemented in C to binascii and use them to greatly improve the performance and reduce the memory usage of the existing base32 codec functions in ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noned6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/146193/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F146193%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F146193%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/146193/files
Reloadhttps://github.com/python/cpython/pull/146193/files
Reloadhttps://github.com/python/cpython/pull/146193/files
Please reload this pagehttps://github.com/python/cpython/pull/146193/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/146193/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 34.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.7k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
serhiy-storchakahttps://github.com/serhiy-storchaka
python:mainhttps://github.com/python/cpython/tree/main
kangtastic:base32-accelhttps://github.com/kangtastic/cpython/tree/base32-accel
Conversation 25 https://github.com/python/cpython/pull/146193
Commits 8 https://github.com/python/cpython/pull/146193/commits
Checks 48 https://github.com/python/cpython/pull/146193/checks
Files changed https://github.com/python/cpython/pull/146193/files
Please reload this pagehttps://github.com/python/cpython/pull/146193/files
gh-146192: Add base32 support to binascii https://github.com/python/cpython/pull/146193/files#top
Show all changes 8 commits https://github.com/python/cpython/pull/146193/files
0a8e4b1 gh-146192: Add base32 support to binascii kangtastic Mar 20, 2026 https://github.com/python/cpython/pull/146193/commits/0a8e4b18a58c939186d18cd25848d0fb56718e17
bf1308f Update PR for #145981 kangtastic Mar 20, 2026 https://github.com/python/cpython/pull/146193/commits/bf1308f1f1139fe99411908dc575c17f18d983fa
a9a7d26 Address reviewer feedback kangtastic Mar 21, 2026 https://github.com/python/cpython/pull/146193/commits/a9a7d26463b57fd2a25b79b2466539c438169aa1
6f80c54 Update generated files kangtastic Mar 21, 2026 https://github.com/python/cpython/pull/146193/commits/6f80c549a6e34762cde54502d24c9cee98e7079f
4c82070 Address more reviewer feedback kangtastic Mar 22, 2026 https://github.com/python/cpython/pull/146193/commits/4c8207076deddadc0521ea5d3b3e733c98280711
58707ea Rename references to groups of 5 and 8 bytes kangtastic Mar 22, 2026 https://github.com/python/cpython/pull/146193/commits/58707ea61a6bcf24bf83fe0c486b50b4b062c1cb
e3ee6df Minor polishing changes kangtastic Mar 22, 2026 https://github.com/python/cpython/pull/146193/commits/e3ee6df8be3f197fd3cb1fc11dd68b37317bdd58
6c9db0d binascii.c: Modify exception behavior on invalid encoded length kangtastic Mar 22, 2026 https://github.com/python/cpython/pull/146193/commits/6c9db0d673925e941a206d312e78a6d6c20df27b
Clear filters https://github.com/python/cpython/pull/146193/files
Please reload this pagehttps://github.com/python/cpython/pull/146193/files
Please reload this pagehttps://github.com/python/cpython/pull/146193/files
binascii.rst https://github.com/python/cpython/pull/146193/files#diff-d8ff111ba7edab3404f42600a80f1a78c62dedaef5783cd5fa59d9dce0ba232f
3.15.rst https://github.com/python/cpython/pull/146193/files#diff-bd7a9c5b54eeb2b40e6db5e48e8d79d309d8738e776a40918773c6840189edf9
base64.py https://github.com/python/cpython/pull/146193/files#diff-1d196d93fbeed5133b0bc9de7b58a2f5a0caee15e693ba605c7182d127e7f263
test_binascii.py https://github.com/python/cpython/pull/146193/files#diff-aeec59865b47d3778520e9e507ff5ee4c06d96434433669b1abc4d36d425bde5
2026-03-20-00-39-25.gh-issue-146192.8aQ6sC.rst https://github.com/python/cpython/pull/146193/files#diff-92f913a064886463d9ee3e24f8be1c2ae047b9e8e55d7c7b226eb0f654448ec5
binascii.c https://github.com/python/cpython/pull/146193/files#diff-ba5e0c9b1d3a07e484b80157530df909d6cbc13e479e464e9fe0e7744822653c
binascii.c.h https://github.com/python/cpython/pull/146193/files#diff-e34d4c9e0ce6432d401a8778474cb8e8808d3fa11e8742e056df7d0c9f6fbeaf
Doc/library/binascii.rsthttps://github.com/python/cpython/pull/146193/files#diff-d8ff111ba7edab3404f42600a80f1a78c62dedaef5783cd5fa59d9dce0ba232f
View file https://github.com/kangtastic/cpython/blob/6c9db0d673925e941a206d312e78a6d6c20df27b/Doc/library/binascii.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/146193/{{ revealButtonHref }}
https://github.com/python/cpython/pull/146193/files#diff-d8ff111ba7edab3404f42600a80f1a78c62dedaef5783cd5fa59d9dce0ba232f
Please reload this pagehttps://github.com/python/cpython/pull/146193/files
https://github.com/python/cpython/pull/146193/files#diff-d8ff111ba7edab3404f42600a80f1a78c62dedaef5783cd5fa59d9dce0ba232f
https://github.com/python/cpython/pull/146193/files#diff-d8ff111ba7edab3404f42600a80f1a78c62dedaef5783cd5fa59d9dce0ba232f
Please reload this pagehttps://github.com/python/cpython/pull/146193/files
https://github.com/python/cpython/pull/146193/files#diff-d8ff111ba7edab3404f42600a80f1a78c62dedaef5783cd5fa59d9dce0ba232f
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L116
Doc/whatsnew/3.15.rsthttps://github.com/python/cpython/pull/146193/files#diff-bd7a9c5b54eeb2b40e6db5e48e8d79d309d8738e776a40918773c6840189edf9
View file https://github.com/kangtastic/cpython/blob/6c9db0d673925e941a206d312e78a6d6c20df27b/Doc/whatsnew/3.15.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/146193/{{ revealButtonHref }}
https://github.com/python/cpython/pull/146193/files#diff-bd7a9c5b54eeb2b40e6db5e48e8d79d309d8738e776a40918773c6840189edf9
https://github.com/python/cpython/pull/146193/files#diff-bd7a9c5b54eeb2b40e6db5e48e8d79d309d8738e776a40918773c6840189edf9
https://github.com/python/cpython/pull/146193/files#diff-bd7a9c5b54eeb2b40e6db5e48e8d79d309d8738e776a40918773c6840189edf9
https://github.com/python/cpython/pull/146193/files#diff-bd7a9c5b54eeb2b40e6db5e48e8d79d309d8738e776a40918773c6840189edf9
Lib/base64.pyhttps://github.com/python/cpython/pull/146193/files#diff-1d196d93fbeed5133b0bc9de7b58a2f5a0caee15e693ba605c7182d127e7f263
View file https://github.com/kangtastic/cpython/blob/6c9db0d673925e941a206d312e78a6d6c20df27b/Lib/base64.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/146193/{{ revealButtonHref }}
https://github.com/python/cpython/pull/146193/files#diff-1d196d93fbeed5133b0bc9de7b58a2f5a0caee15e693ba605c7182d127e7f263
serhiy-storchakahttps://github.com/serhiy-storchaka
Mar 21, 2026https://github.com/python/cpython/pull/146193/files#r2969416790
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/146193/files
serhiy-storchakahttps://github.com/serhiy-storchaka
Mar 22, 2026https://github.com/python/cpython/pull/146193/files#r2971228504
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/146193/files
https://github.com/python/cpython/pull/146193/files#diff-1d196d93fbeed5133b0bc9de7b58a2f5a0caee15e693ba605c7182d127e7f263
https://github.com/python/cpython/pull/146193/files#diff-1d196d93fbeed5133b0bc9de7b58a2f5a0caee15e693ba605c7182d127e7f263
Please reload this pagehttps://github.com/python/cpython/pull/146193/files
Please reload this pagehttps://github.com/python/cpython/pull/146193/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.