Antoine Pitrou added the comment:

Non-greedy matching actually makes things worse :-)

$ ./python -m timeit -s "import re; pat = re.compile('\A*a*a*a\Z'.replace('*', 
'[^.]+'), re.IGNORECASE)" "pat.match('a' * 100 +'z')"
100 loops, best of 3: 3.31 msec per loop

$ ./python -m timeit -s "import re; pat = re.compile('\A*a*a*a\Z'.replace('*', 
'[^.]+?'), re.IGNORECASE)" "pat.match('a' * 100 +'z')"
100 loops, best of 3: 6.91 msec per loop

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17980>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to