This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients ezio.melotti, mrabarnett, python-dev, serhiy.storchaka, vstinner
Date 2016-11-23.08:09:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1479888569.07.0.698365705404.issue28765@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2016-11-23 08:09:29serhiy.storchakasetrecipients: + serhiy.storchaka, vstinner, ezio.melotti, mrabarnett, python-dev
2016-11-23 08:09:29serhiy.storchakasetmessageid: <1479888569.07.0.698365705404.issue28765@psf.upfronthosting.co.za>
2016-11-23 08:09:28serhiy.storchakalinkissue28765 messages
2016-11-23 08:09:28serhiy.storchakacreate