[issue34599] improve performance of _Py_bytes_capitalize()

2018-09-07 Thread STINNER Victor


STINNER Victor  added the comment:

Nice optimization Sergey Fedoseev, thanks!

--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34599] improve performance of _Py_bytes_capitalize()

2018-09-06 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset 593bb30e82eded7f2ec02f7d1aa49742e6962113 by Benjamin Peterson 
(Sergey Fedoseev) in branch 'master':
closes bpo-34599: Improve performance of _Py_bytes_capitalize(). (GH-9083)
https://github.com/python/cpython/commit/593bb30e82eded7f2ec02f7d1aa49742e6962113


--
nosy: +benjamin.peterson
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34599] improve performance of _Py_bytes_capitalize()

2018-09-06 Thread Sergey Fedoseev


Change by Sergey Fedoseev :


--
keywords: +patch
pull_requests: +8541
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34599] improve performance of _Py_bytes_capitalize()

2018-09-06 Thread Sergey Fedoseev


New submission from Sergey Fedoseev :

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'*1000" "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'*1000" "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'*1000" "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%)

--
components: Interpreter Core
messages: 324707
nosy: sir-sigurd
priority: normal
severity: normal
status: open
title: improve performance of _Py_bytes_capitalize()
type: performance
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com