[issue17170] string method lookup is too slow

Guido van Rossum report at bugs.python.org
Sat Feb 9 17:18:55 CET 2013


Guido van Rossum added the comment:

Hm, you seem to be right. Changing the bug title.

So, can we speed up method lookup? It's a shame that I have to start promoting this ugly idiom. There's a similar issue where s[:5]=='abcde' is faster than s.startswith('abcde'):

./python.exe -m timeit -s "a = 'hundred'" "a.startswith('foo')"
1000000 loops, best of 3: 0.281 usec per loop

./python.exe -m timeit -s "a = 'hundred'" "a[:3] == 'foo'"
10000000 loops, best of 3: 0.158 usec per loop

----------
title: string replace is too slow -> string method lookup is too slow

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17170>
_______________________________________


More information about the Python-bugs-list mailing list