[Python-Dev] New stringbench benchmark results (original) (raw)
Victor Stinner victor.stinner at haypocalc.com
Fri Oct 7 13:44:13 CEST 2011
- Previous message: [Python-Dev] New stringbench benchmark results
- Next message: [Python-Dev] New stringbench benchmark results
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] New stringbench benchmark results
- Next message: [Python-Dev] New stringbench benchmark results
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]