[Python-Dev] New stringbench benchmark results
Victor Stinner
victor.stinner at haypocalc.com
Fri Oct 7 13:44:13 CEST 2011
Le 07/10/2011 03:19, Steven D'Aprano a écrit :
> Given that strings are immutable, would it not be an obvious
> optimization for replace to return the source string unchanged if the
> old and new substrings are equal, and avoid making a potentially
> expensive copy?
I just implemented this optimization in 9c1b76936b79, but only if old
and new substrings are the same object (old is new). *Compare*
substrings (content) would slow down .replace() in most cases.
Victor
More information about the Python-Dev
mailing list