This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients azsorkin, louielu, malin, methane, ned.deily, pitrou, python-dev, serhiy.storchaka, vstinner, xiang.zhang
Date 2017-03-29.13:32:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490794372.35.0.140395450638.issue24821@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2017-03-29 13:32:52serhiy.storchakasetrecipients: + serhiy.storchaka, pitrou, vstinner, ned.deily, methane, python-dev, malin, azsorkin, xiang.zhang, louielu
2017-03-29 13:32:52serhiy.storchakasetmessageid: <1490794372.35.0.140395450638.issue24821@psf.upfronthosting.co.za>
2017-03-29 13:32:52serhiy.storchakalinkissue24821 messages
2017-03-29 13:32:52serhiy.storchakacreate