STINNER Victor added the comment: Oh, I tested the wrong patch :-( Here is the updated benchmark summary:
---------------------------+--------------+--------------- Summary | original | writer ---------------------------+--------------+--------------- replace none, length=10 | 5.65 us (*) | 5.53 us replace none, length=10**3 | 489 us (*) | 475 us replace none, length=10**6 | 487 ms (*) | 476 ms replace 10%, length=10 | 5.47 us (*) | 5.25 us replace 10%, length=10**3 | 455 us (*) | 447 us replace 10%, length=10**6 | 455 ms (*) | 447 ms replace 50%, length=10 | 4.71 us (*) | 4.42 us (-6%) replace 50%, length=10**3 | 372 us (*) | 352 us (-5%) replace 50%, length=10**6 | 371 ms (*) | 352 ms (-5%) replace 90%, length=10 | 3.88 us (*) | 3.53 us (-9%) replace 90%, length=10**3 | 293 us (*) | 270 us (-8%) replace 90%, length=10**6 | 293 ms (*) | 271 ms (-7%) replace all, length=10 | 3.58 us (*) | 3.24 us (-10%) replace all, length=10**3 | 263 us (*) | 236 us (-10%) replace all, length=10**6 | 262 ms (*) | 235 ms (-10%) ---------------------------+--------------+--------------- Total | 1.87 sec (*) | 1.78 sec ---------------------------+--------------+--------------- str.translate() is a little bit faster with translate_writer.patch, but I don't really care if it's not faster, it's just to cleanup to code. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21118> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com