Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-124951: Optimize base64 encode & decode for an easy 2-3x speedup [no SIMD]#143262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gpshead merged 13 commits intopython:mainfromgpshead:opt-base64-cpu
Jan 2, 2026
Merged
Changes from1 commit
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
2d2be30
Add base64 benchmark tool and optimize encoding/decoding
gpsheadDec 28, 2025
573eaf3
Fix MSVC build: move table_b2a_base64 before inline functions
gpsheadDec 29, 2025
eaac671
NEWS entry
gpsheadDec 29, 2025
060dbf5
Add a whatsnew entry
gpsheadDec 29, 2025
1e12273
expose the benchmark defaults in the help text.
gpsheadDec 29, 2025
ef38895
Align base64 tables to 64-byte cache line boundaries
gpsheadDec 29, 2025
7458c99
Use BASE64_PAD macro instead of literal '=' in fast path
gpsheadDec 29, 2025
1f8ff74
Simplify block comment for base64 helpers
gpsheadDec 29, 2025
4b1245b
Remove binasciibench in favor of pyperformance bm_base64 addition PR.
gpsheadDec 29, 2025
4b50c73
reword L1 cache line comment
gpsheadJan 2, 2026
f7b27ee
doc Contributed by
gpsheadJan 2, 2026
2b13b81
Remove redundant PAD check in base64 decode fast path
gpsheadJan 2, 2026
30976a9
Use pointer increment in base64_encode_fast
gpsheadJan 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
Use pointer increment in base64_encode_fast
Suggested by serhiy-storchaka: replace index math (in + i*3, out + i*4)with pointer increments. Encode is ~7% faster at 64K (2.11 → 2.25 GB/s).🤖 Generated with [Claude Code](https://claude.com/claude-code)Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
  • Loading branch information
@gpshead@claude
gpshead andclaude committedJan 2, 2026
commit30976a90eb3a6cb5383ced997fd8fd2ab6fa018a

Some comments aren't visible on the classic Files Changed page.

8 changes: 5 additions & 3 deletionsModules/binascii.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -134,10 +134,12 @@ base64_encode_fast(const unsigned char *in, Py_ssize_t in_len,
unsigned char *out, const unsigned char *table)
{
Py_ssize_t n_trios = in_len / 3;
Py_ssize_t i;
const unsigned char *in_end = in + n_trios * 3;

for (i = 0; i < n_trios; i++) {
base64_encode_trio(in + i * 3, out + i * 4, table);
while (in < in_end) {
base64_encode_trio(in, out, table);
in += 3;
out += 4;
}

return n_trios * 3;
Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp