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 sir-sigurd
Recipients sir-sigurd
Date 2018-09-06.18:12:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1536257534.96.0.56676864532.issue34599@psf.upfronthosting.co.za>
In-reply-to
Content
Currently _Py_bytes_capitalize() checks case before using conversion table, performance can be improved by using conversion table unconditionally. Benchmarks:

$ python -m perf timeit --compare-to ~/tmp/cpython-master-venv/bin/python -s "b = b'0'*10000000" "b.capitalize()"
/home/sergey/tmp/cpython-master-venv/bin/python: ..................... 7.26 ms +- 0.03 ms
/home/sergey/tmp/cpython-dev-venv/bin/python: ..................... 7.27 ms +- 0.04 ms
Mean +- std dev: [/home/sergey/tmp/cpython-master-venv/bin/python] 7.26 ms +- 0.03 ms -> [/home/sergey/tmp/cpython-dev-venv/bin/python] 7.27 ms +- 0.04 ms: 1.00x slower (+0%)
Not significant!

$ python -m perf timeit --compare-to ~/tmp/cpython-master-venv/bin/python -s "b = b'a'*10000000" "b.capitalize()"
/home/sergey/tmp/cpython-master-venv/bin/python: ..................... 7.25 ms +- 0.03 ms
/home/sergey/tmp/cpython-dev-venv/bin/python: ..................... 7.26 ms +- 0.03 ms
Mean +- std dev: [/home/sergey/tmp/cpython-master-venv/bin/python] 7.25 ms +- 0.03 ms -> [/home/sergey/tmp/cpython-dev-venv/bin/python] 7.26 ms +- 0.03 ms: 1.00x slower (+0%)

$ python -m perf timeit --compare-to ~/tmp/cpython-master-venv/bin/python -s "b = b'A'*10000000" "b.capitalize()"
/home/sergey/tmp/cpython-master-venv/bin/python: ..................... 18.1 ms +- 0.0 ms
/home/sergey/tmp/cpython-dev-venv/bin/python: ..................... 7.31 ms +- 0.13 ms
Mean +- std dev: [/home/sergey/tmp/cpython-master-venv/bin/python] 18.1 ms +- 0.0 ms -> [/home/sergey/tmp/cpython-dev-venv/bin/python] 7.31 ms +- 0.13 ms: 2.47x faster (-60%)
History
Date User Action Args
2018-09-06 18:12:15sir-sigurdsetrecipients: + sir-sigurd
2018-09-06 18:12:14sir-sigurdsetmessageid: <1536257534.96.0.56676864532.issue34599@psf.upfronthosting.co.za>
2018-09-06 18:12:14sir-sigurdlinkissue34599 messages
2018-09-06 18:12:14sir-sigurdcreate