Serhiy Storchaka added the comment:
Following patch replaces abstract types API with concrete types API and makes
the memory consumption of the pattern object smaller if there are no named
groups.
$ ./python -m perf timeit -s "import re; m = re.match('(?P<first>first)
(?P<second>second)', 'first second')" -- "m.lastgroup"
Unpatched: Median +- std dev: 89.8 ns +- 1.8 ns
Patched: Median +- std dev: 80.5 ns +- 3.3 ns
$ ./python -m perf timeit -s "import re; m = re.match('(?P<first>first)
(?P<second>second)', 'first second')" -- "m.groupdict()"
Unpatched: Median +- std dev: 803 ns +- 16 ns
Patched: Median +- std dev: 711 ns +- 16 ns
$ ./python -m perf timeit -s "import re; m = re.match('(?P<first>first)
(?P<second>second)', 'first second')" -- "m['first']"
Unpatched: Median +- std dev: 228 ns +- 14 ns
Patched: Median +- std dev: 217 ns +- 11 ns
----------
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett
stage: -> patch review
Added file: http://bugs.python.org/file45607/sre-concrete.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28765>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com