Why is regex so slow?
Skip Montanaro
skip at pobox.com
Tue Jun 18 13:01:26 EDT 2013
> I don't understand why the first way is so much slower.
I have no obvious answers, but a couple suggestions:
1. Can you anchor the pattern at the beginning of the line? (use
match() instead of search())
2. Does it get faster it you eliminate the "(.*)" part of the pattern?
It seems that if you find a line matching the first part of the
pattern, you could just as easily split the line yourself instead of
creating a group.
Skip
More information about the Python-list
mailing list