[issue21118] str.translate is absurdly slow in majority of use cases (takes up to 60x longer than similar functions)
Antoine Pitrou
report at bugs.python.org
Wed Apr 2 17:00:33 CEST 2014
Antoine Pitrou added the comment:
> bytes.translate() is much faster because it builds a C array of 256
> items to fast table lookup, whereas str.translate() requires a Python
> dict lookup for each character, which is much slower.
It should be easy to devise a simple hash table for the common case of one-to-one translation (and also deletion).
----------
nosy: +pitrou
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21118>
_______________________________________
More information about the Python-bugs-list
mailing list