This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Josh Snider
Recipients Josh Snider
Date 2016-03-16.23:28:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458170890.63.0.147886169107.issue26574@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-03-16 23:28:10Josh Snidersetrecipients: + Josh Snider
2016-03-16 23:28:10Josh Snidersetmessageid: <1458170890.63.0.147886169107.issue26574@psf.upfronthosting.co.za>
2016-03-16 23:28:10Josh Sniderlinkissue26574 messages
2016-03-16 23:28:10Josh Snidercreate