Message261870
replace_interleave in Objects/bytesobject.c and Objects/bytearrayobject.c can be optimized for the special case where the interleaving byte string is a single character.
Here's some quick results from timeit showing that it's about three times faster for the special case.
* Before (cold start):
>>> timeit.timeit('(b"x" * 2000000).replace(b"", b".")', number=1000)
7.619218342995737
* After (cold start):
>>> timeit.timeit('(b"x" * 2000000).replace(b"", b".")', number=1000)
2.7605581780080684
For the non-special case, running timeit.timeit('(b"x" * 2000000).replace(b"", b".0")', number=10000) takes ~173 seconds on both versions. |
|
Date |
User |
Action |
Args |
2016-03-16 23:28:10 | Josh Snider | set | recipients:
+ Josh Snider |
2016-03-16 23:28:10 | Josh Snider | set | messageid: <1458170890.63.0.147886169107.issue26574@psf.upfronthosting.co.za> |
2016-03-16 23:28:10 | Josh Snider | link | issue26574 messages |
2016-03-16 23:28:10 | Josh Snider | create | |
|