Seeking regex optimizer
andrewdalke at gmail.com
andrewdalke at gmail.com
Mon Jun 19 19:39:25 EDT 2006
Replying to me Mirco Wahab wrote:
> If you pull the strings into (?>( ... )) (atomic groups),
> this would't happen.
Given that Python's re engine doesn't support this feature
it doesn't really help the original poster's problem.
Even if some future Python did support it, the limit
to 100 named groups is unaffected by backtracking.
>>> import re
>>> re.compile("(.)"*100)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/sre.py",
line 180, in compile
return _compile(pattern, flags)
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/sre.py",
line 225, in _compile
p = sre_compile.compile(pattern, flags)
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/sre_compile.py",
line 506, in compile
raise AssertionError(
AssertionError: sorry, but this version only supports 100 named groups
>>>
There was no backtracking in "(.)"*100.
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list