Skip to content

Conversation

@gpshead
Copy link
Member

Motivation python/cpython#143262 but also in general this wasn't covered and @serhiy-storchaka is also doing work in this area that'll become relevant such as python/cpython#143216.

@gpshead

This comment was marked as resolved.

@gpsheadgpshead marked this pull request as ready for review December 29, 2025 05:59
Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the results and the total time?

My suggestions:

  • Test an ASCII string input for decoding.
  • Balance encoding and decoding.

@gpshead
Copy link
MemberAuthor

Example results comparing before and after python/cpython#143262.

main-before-opt-b64.json ======================== Performance version: 1.14.0 Python version: 3.15.0a3+ (64-bit) revision 6b9a6c6ec3b Report on Linux-6.17.0-8-generic-x86_64-with-glibc2.42 Number of logical CPUs: 15 Start date: 2026-01-02 06:47:53.863590 End date: 2026-01-02 06:54:17.985677 main-after-opt-b64.json ======================= Performance version: 1.14.0 Python version: 3.15.0a3+ (64-bit) revision 61fc72a4a43 Report on Linux-6.17.0-8-generic-x86_64-with-glibc2.42 Number of logical CPUs: 15 Start date: 2026-01-02 06:30:08.791666 End date: 2026-01-02 06:36:26.047033 ### ascii85_large ### Mean +- std dev: 1.04 sec +- 0.01 sec -> 1.03 sec +- 0.01 sec: 1.01x faster Not significant ### ascii85_small ### Mean +- std dev: 20.7 ms +- 0.3 ms -> 20.6 ms +- 0.4 ms: 1.00x faster Not significant ### base16_large ### Mean +- std dev: 6.39 ms +- 0.06 ms -> 6.36 ms +- 0.04 ms: 1.00x faster Not significant ### base16_small ### Mean +- std dev: 376 us +- 3 us -> 372 us +- 3 us: 1.01x faster Not significant ### base32_large ### Mean +- std dev: 585 ms +- 8 ms -> 586 ms +- 7 ms: 1.00x slower Not significant ### base32_small ### Mean +- std dev: 11.4 ms +- 0.1 ms -> 11.5 ms +- 0.1 ms: 1.00x slower Not significant ### base64_large ### Mean +- std dev: 4.66 ms +- 0.03 ms -> 2.06 ms +- 0.01 ms: 2.26x faster Significant (t=749.12) ### base64_small ### Mean +- std dev: 314 us +- 5 us -> 253 us +- 5 us: 1.24x faster Significant (t=64.73) ### base85_large ### Mean +- std dev: 432 ms +- 4 ms -> 431 ms +- 4 ms: 1.00x faster Not significant ### base85_small ### Mean +- std dev: 8.37 ms +- 0.08 ms -> 8.39 ms +- 0.12 ms: 1.00x slower Not significant ### urlsafe_base64_small ### Mean +- std dev: 511 us +- 5 us -> 445 us +- 4 us: 1.15x faster Significant (t=80.03) 

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to add also ignorechars to support decoding multi-line data. So it may be worth to separate "raw" and "multi-line" cases, if we want to compare the effect of optimization. We could also separate encoding and decoding. But then we will have too much tests. So this is up to you.

@gpshead
Copy link
MemberAuthor

yeah i'd initially started out with separate encode/decode but the matrix of benchmark cases got large and pyperformance is not really intended as a microbenchmark. improvements in any of these will be reflected in the overall scores.

@gpsheadgpshead merged commit 0976e4a into python:mainJan 3, 2026
19 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@gpshead@serhiy-storchaka