New submission from Antoine Pitrou <pit...@free.fr>: With some gcc versions, str.find() is slower than str.rfind():
- 11.22 0.0 s="ABC"*33; ((s+"D")*500+s+"E").find(s+"E") (*100) - 4.56 0.0 s="ABC"*33; ((s+"D")*500+"E"+s).find("E"+s) (*100) - 6.71 0.0 s="ABC"*33; (s+"E") in ((s+"D")*300+s+"E") (*100) - 11.22 0.0 s="ABC"*33; ((s+"D")*500+s+"E").index(s+"E") (*100) - 11.52 0.0 s="ABC"*33; ((s+"D")*500+s+"E").partition(s+"E") (*100) - 8.79 0.0 s="ABC"*33; ("E"+s+("D"+s)*500).rfind("E"+s) (*100) - 3.86 0.0 s="ABC"*33; (s+"E"+("D"+s)*500).rfind(s+"E") (*100) - 8.80 0.0 s="ABC"*33; ("E"+s+("D"+s)*500).rindex("E"+s) (*100) - 9.80 0.0 s="ABC"*33; ("E"+s+("D"+s)*500).rpartition("E"+s) (*100) - 9.83 0.0 s="ABC"*33; ("E"+s+("D"+s)*500).rsplit("E"+s, 1) (*100) - 11.56 0.0 s="ABC"*33; ((s+"D")*500+s+"E").split(s+"E", 1) (*100) Attached patch seems to fix it. ---------- components: Interpreter Core files: findperf.patch keywords: patch messages: 145136 nosy: haypo, pitrou priority: low severity: normal status: open title: find() slower than rfind() type: performance versions: Python 3.3 Added file: http://bugs.python.org/file23339/findperf.patch _______________________________________ 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