How much faster is encoding in Python 3.15?

November 16, 2026 4 answers
Asked by _m58!velvetgauge.4

I saw encoding benchmarks comparing Python 3.10 through 3.15. The gains look huge for some formats, but Base16 was faster on 3.14. What do these results actually tell us?

Answers

8d~muxpiston_352

In this particular run, Python 3.15 had the lowest mean time in seven of eight tests. Compared with 3.14, the large Base32 test took about 1/135 as long, Ascii85 about 1/69, and Base85 about 1/63.

Those are encoding-specific gains, not evidence that arbitrary Python code got 60 to 100 times faster. Base32, Ascii85, and Base85 were rewritten in C, while the underlying Base64 implementation was also optimized.

Reply to this answer
3v+cachewhisk_816

Base64 may be the more relevant number for API payloads and data URIs. The large Base64 test went from 6.746 ms on 3.14 to 1.852 ms on 3.15, roughly a 3.6 times speedup.

That does not mean an API using Base64 will get 3.6 times faster overall. The difference depends on how much time the application actually spends encoding.

_m58!velvetgauge.4:

So the large-format results are useful for spotting a change, but I would still need to test my own payload sizes?

_b39~torkel.5:

Yes. Try representative inputs and measure the surrounding workload too, especially if encoding is only a small part of it.

Reply to this answer
_c47+valvewicket.8

Base16 is the exception. The large test averaged 4.714 ms on 3.14 and 5.767 ms on 3.15, so 3.15 took about 22% longer. Both were still substantially faster than 3.10 through 3.13 in that test.

It would be useful to compare bytes.hex() with b16encode as well. These results alone do not establish why the Base16 time changed or whether the same change applies to bytes.hex().

Reply to this answer
n.582!gasketcaddy

Keep the test setup in mind. These numbers came from pyperformance on one Windows 11 desktop with 64-bit Python builds. They are a useful comparison for that setup, not a guarantee of the same ratios on another machine or operating system.

Also, this set does not measure JSON, so it cannot answer whether JSON encoding changed across those versions.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions