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 <>
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)
* After (cold start):
>>> timeit.timeit('(b"x" * 2000000).replace(b"", b".")', number=1000)

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:10Josh Snidersetrecipients: + Josh Snider
2016-03-16 23:28:10Josh Snidersetmessageid: <>
2016-03-16 23:28:10Josh Sniderlinkissue26574 messages
2016-03-16 23:28:10Josh Snidercreate