Re: [Python-Dev] New stringbench benchmark results

2011-10-07 Thread Victor Stinner
Le jeudi 6 octobre 2011 02:06:30, Victor Stinner a écrit : > The rfind case is really strange: the code between Python 3.2 and 3.3 is > exactly the same. Even in Python 3.2: rfind looks twice faster than find: > > ("AB"*300+"C").find("BC") (*1000) : 1.21 > ("C"+"AB"*300).rfind("CA") (*1000) : 0.57

Re: [Python-Dev] New stringbench benchmark results

2011-10-07 Thread Victor Stinner
Le 06/10/2011 12:42, Victor Stinner a écrit : "A".join(["Bob"]*100)): 0.92 => 2.11 I just optimized PyUnicode_Join() for such dummy benchmark. It's now 1.2x slower instead of 2.3x slower on this dummy benchmark. With longer *ASCII* strings, Python 3.3 is now 2x (narrow 3.2) or 4x (wide 3.2

Re: [Python-Dev] New stringbench benchmark results

2011-10-07 Thread Victor Stinner
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

Re: [Python-Dev] New stringbench benchmark results

2011-10-06 Thread Greg Ewing
Steven D'Aprano wrote: 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, Only if this situation occurs frequently enough to outweigh the overhead of comparing the target and repl

Re: [Python-Dev] New stringbench benchmark results

2011-10-06 Thread Steven D'Aprano
Victor Stinner wrote: Hum, copy-paste failure, I wrote numbers in the wrong order, it's: (test: Python 3.2 => Python 3.3) "A".join(["Bob"]*100)): 0.92 => 2.11 ("C"+"AB"*300).rfind("CA"): 0.57 => 1.03 ("A" + ("Z"*128*1024)).replace("A", "BB", 1): 0.25 => 0.50 I improved str.replace(): it's now 5

Re: [Python-Dev] New stringbench benchmark results

2011-10-06 Thread Victor Stinner
Hum, copy-paste failure, I wrote numbers in the wrong order, it's: (test: Python 3.2 => Python 3.3) "A".join(["Bob"]*100)): 0.92 => 2.11 ("C"+"AB"*300).rfind("CA"): 0.57 => 1.03 ("A" + ("Z"*128*1024)).replace("A", "BB", 1): 0.25 => 0.50 I improved str.replace(): it's now 5 times faster instead of

[Python-Dev] New stringbench benchmark results

2011-10-05 Thread Victor Stinner
Hi, I optimized unicodeobject.c a little bit more where I saw major performance regressions from Python 3.2 to 3.3 using stringbench. Here are new results: see attachments. Example of tests where Python 3.3 is much slower: "A".join(["Bob"]*100)): 2.11 => 0.92 ("C"+"AB"*300).rfind("CA"): 0.57 =>