gh-146192: Add base32 support to binascii#146193
Open
kangtastic wants to merge 2 commits intopython:mainfrom
Open
gh-146192: Add base32 support to binascii#146193kangtastic wants to merge 2 commits intopython:mainfrom
kangtastic wants to merge 2 commits intopython:mainfrom
Conversation
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: pythongh-146192
Member
|
You can now update your PR, @kangtastic. |
Contributor
Author
|
@serhiy-storchaka Already on it 😄 |
- Use the new `alphabet` parameter in `binascii` - Remove `binascii.a2b_base32hex()` and `binascii.b2a_base32hex()` - Change value for `.. versionadded::` ReST directive in docs for new `binascii` functions to "next" instead of "3.15"
db96a3f to
bf1308f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Synopsis
Add base32 encoder and decoder functions implemented in C to
binasciiand use them to greatly improve the performance and reduce the memory usage of the existing base32 codec functions inbase64.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
base64are now wrappers for the new functions inbinascii, as envisioned in the docs:Comments and questions are welcome.
Benchmarks
Benchmark script
Unmodified mainline CPython
With this PR
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/