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 vstinner
Recipients Josh Snider, vstinner
Date 2016-03-21.09:39:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458553165.77.0.18897003328.issue26574@psf.upfronthosting.co.za>
In-reply-to
Content
I wrote a microbenchmark with my benchmark.py tool.

The patch always make bytes.replace(b'', char) and bytearray.replace(b'', char) faster even for strings of 10 bytes, the speedup on string of 1000 bytes or more is very interesting, even I never used this Python instruction :-)

-------------+-------------+---------------
type bytes   |        orig |          patch
-------------+-------------+---------------
length=10    |  250 ns (*) |  211 ns (-15%)
length=10**3 | 4.67 us (*) | 1.07 us (-77%)
length=10**5 |  441 us (*) | 78.2 us (-82%)
-------------+-------------+---------------
Total        |  446 us (*) | 79.5 us (-82%)
-------------+-------------+---------------

---------------+-------------+---------------
type bytearray |        orig |          patch
---------------+-------------+---------------
length=10      |  266 ns (*) |  224 ns (-16%)
length=10**3   | 4.67 us (*) | 1.08 us (-77%)
length=10**5   |  441 us (*) | 78.3 us (-82%)
---------------+-------------+---------------
Total          |  446 us (*) | 79.6 us (-82%)
---------------+-------------+---------------

---------------+------------+---------------
Summary        |       orig |          patch
---------------+------------+---------------
type bytes     | 446 us (*) | 79.5 us (-82%)
type bytearray | 446 us (*) | 79.6 us (-82%)
---------------+------------+---------------
Total          | 892 us (*) |  159 us (-82%)
---------------+------------+---------------
History
Date User Action Args
2016-03-21 09:39:25vstinnersetrecipients: + vstinner, Josh Snider
2016-03-21 09:39:25vstinnersetmessageid: <1458553165.77.0.18897003328.issue26574@psf.upfronthosting.co.za>
2016-03-21 09:39:25vstinnerlinkissue26574 messages
2016-03-21 09:39:25vstinnercreate