[issue31979] Simplify converting non-ASCII strings to int, float and complex

Serhiy Storchaka report at bugs.python.org
Mon Nov 13 14:22:00 EST 2017


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

As a side effect it slightly optimizes parsing non-ASCII numbers.

$ ./python -m perf timeit --compare-to=./python0  'int("۱۲۳۴۵۶۷۸۹")' --duplicate 100
python0: ..................... 277 ns +- 3 ns
python: ..................... 225 ns +- 3 ns

Mean +- std dev: [python0] 277 ns +- 3 ns -> [python] 225 ns +- 3 ns: 1.23x faster (-19%)

$ ./python -m perf timeit --compare-to=./python0  'float("۱۲۳۴۵.۶۷۸۹")' --duplicate 100
python0: ..................... 256 ns +- 1 ns
python: ..................... 199 ns +- 2 ns

Mean +- std dev: [python0] 256 ns +- 1 ns -> [python] 199 ns +- 2 ns: 1.29x faster (-22%)

$ ./python -m perf timeit --compare-to=./python0  'complex("۱۲۳۴۵.۶۷۸۹j")' --duplicate 100
python0: ..................... 298 ns +- 4 ns
python: ..................... 235 ns +- 3 ns

Mean +- std dev: [python0] 298 ns +- 4 ns -> [python] 235 ns +- 3 ns: 1.27x faster (-21%)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31979>
_______________________________________


More information about the Python-bugs-list mailing list