[issue28765] _sre.compile(): be more strict on types of indexgroup and groupindex
Serhiy Storchaka
report at bugs.python.org
Wed Apr 5 14:36:50 EDT 2017
Serhiy Storchaka added the comment:
The patch makes some operations slightly faster.
$ ./python -m perf timeit -s 'import re; m = re.match(r"(?P<int>\d+)(?:\.(?P<frac>\d*))?", "12.34")' -- --duplicate 100 'm.lastgroup'
Unpatched: Median +- std dev: 204 ns +- 1 ns
Patched: Median +- std dev: 167 ns +- 2 ns
$ ./python -m perf timeit -s 'import re; m = re.match(r"(?P<int>\d+)(?:\.(?P<frac>\d*))?", "12.34")' -- --duplicate 100 'm.groupdict()'
Unpatched: Median +- std dev: 2.78 us +- 0.05 us
Patched: Median +- std dev: 1.98 us +- 0.04 us
$ ./python -m perf timeit -s 'import re; m = re.match(r"(?P<int>\d+)(?:\.(?P<frac>\d*))?", "12.34")' -- --duplicate 100 'm.start("frac")'
Unpatched: Median +- std dev: 638 ns +- 22 ns
Patched: Median +- std dev: 576 ns +- 16 ns
$ ./python -m perf timeit -s 'import re; m = re.match(r"(?P<int>\d+)(?:\.(?P<frac>\d*))?", "12.34")' -- --duplicate 100 'm.group("frac")'
Unpatched: Median +- std dev: 1.15 us +- 0.03 us
Patched: Median +- std dev: 1.07 us +- 0.03 us
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28765>
_______________________________________
More information about the Python-bugs-list
mailing list