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 It looks to be a gcc bug: using attached patch (written by Antoine), str.find() is a little bit faster. With the patch, the function does the same memory access, but it generates a different machine code. I don't know exactly the difference yet, but it may be related to the CMOVNE instruction (which looks to be slower than a classical conditional jump, JNE). Victor -------------- next part -------------- A non-text attachment was scrubbed... Name: fastsearch_gcc_bug.patch Type: text/x-patch Size: 1431 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-dev/attachments/20111007/88c504c5/attachment.bin>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4