STINNER Victor added the comment:

I still see a difference between find and rfind, even if the different is low 
(11%).

$ ./python -m timeit -s 's="ABC"*33; a=((s+"D")*500+s+"E"); b=s+"E"' 'a.find(b)'
10000 loops, best of 3: 93.6 usec per loop
$ ./python -m timeit -s 's="ABC"*33; a=("E"+s+("D"+s)*500); b="E"+s' 
'a.rfind(b)'
10000 loops, best of 3: 84.3 usec per loop

Patched Python:

$ ./python -m timeit -s 's="ABC"*33; a=((s+"D")*500+s+"E"); b=s+"E"' 'a.find(b)'
10000 loops, best of 3: 84.7 usec per loop
$ ./python -m timeit -s 's="ABC"*33; a=("E"+s+("D"+s)*500); b="E"+s' 
'a.rfind(b)'
10000 loops, best of 3: 84.5 usec per loop

I'm unable to explain why GCC (4.7 in my case) produces faster code with the 
patch, but the patch is simple and does not make the code (much) harder to 
understand.

So Antoine, please go ahead and apply it.

----------
versions: +Python 3.4 -Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13126>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to