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 <rep...@bugs.python.org>
<http://bugs.python.org/issue28765>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to