STINNER Victor added the comment: translate_script.py: microbenchmark for str.translate() with various length, charsets (ASCII, latin1, UCS2, UCS4) and percentage of replacement. Result:
---------------------------+----------+--------- Summary | original | writer ---------------------------+------+--------- replace none, length=10 | 5.65 us | 5.67 us replace none, length=10**3 | 489 us | 486 us replace none, length=10**6 | 487 ms | 484 ms replace 10%, length=10 | 5.47 us | 5.48 us replace 10%, length=10**3 | 455 us | 455 us replace 10%, length=10**6 | 455 ms | 455 ms replace 50%, length=10 | 4.71 us | 4.7 us replace 50%, length=10**3 | 372 us | 374 us replace 50%, length=10**6 | 371 ms | 373 ms replace 90%, length=10 | 3.88 us | 3.93 us replace 90%, length=10**3 | 293 us | 297 us replace 90%, length=10**6 | 293 ms | 295 ms replace all, length=10 | 3.58 us | 3.59 us replace all, length=10**3 | 263 us | 262 us replace all, length=10**6 | 262 ms | 261 ms ---------------------------+----------+--------- Total | 1.87 sec | 1.87 sec ---------------------------+----------+--------- It's exactly the same with translate_writer.patch. ---------- Added file: http://bugs.python.org/file34727/translate_script.py _______________________________________ 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