[issue24426] re.split performance degraded significantly by capturing group
Serhiy Storchaka
report at bugs.python.org
Sat Jun 13 17:51:36 CEST 2015
Serhiy Storchaka added the comment:
This is a reason to file a feature request to regex. In 3.3 re was slower than regex in some cases:
$ ./python -m timeit -s "import re; p = re.compile('\n\r'); s = ('a'*100 + '\n\r')*1000" -- "p.split(s)"
Python 3.3 re : 1000 loops, best of 3: 952 usec per loop
Python 3.4 regex: 1000 loops, best of 3: 757 usec per loop
Python 3.4 re : 1000 loops, best of 3: 323 usec per loop
And this optimization (issue18685 or others) can be applied to regex.
As for this particular issue, the optimization of splitting with 1-character capturing group needs changes to C part of re engine. Python part of my patch is not needed for this, it is here only for generalizing support of other corner cases. So this issue can't be fixed with patching only Python code.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24426>
_______________________________________
More information about the Python-bugs-list
mailing list