Serhiy Storchaka added the comment: Thank you for testing Louie. Thank you for your review and testing Xiang.
> Would it completely kill performances to remove the optimization? Yes. The optimization is not used if the lowest byte is 0. You can try to search "\0" for getting the result without the optimization. On my netbook the optimization speeds up searching by 5.5 times. Search with optimization: $ ./python -m perf timeit -s 's = "АБВГД"*10**5' -- 's.find("Ж")' Median +- std dev: 296 us +- 33 us Search without optimization: $ ./python -m perf timeit -s 's = "АБВГД"*10**5' -- 's.find("\0")' Median +- std dev: 1.65 ms +- 0.10 ms Search an unlucky character (unpatched): $ ./python -m perf timeit -s 's = "АБВГД"*10**5' -- 's.find("Є")' Median +- std dev: 14.7 ms +- 1.8 ms Search an unlucky character (patched): $ ./python -m perf timeit -s 's = "АБВГД"*10**5' -- 's.find("Є")' Median +- std dev: 2.17 ms +- 0.24 ms ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24821> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com