Step 1) Install pyre2 2) import re2 as re 3) 10x faster regex
github.com
github.com
Also, here's a great bit of technical history behind Russ' re2 implementation, and why pyre2 will never be completely compatible with Python's re (without fallback):
http://swtch.com/~rsc/regexp/regexp1.html
It would be interesting to see if this could make it in Python 3.2 (It's supposed to include the Unladen Swallow stuff, so might as well take more awesomeness from Google.)
Did anyone else experience this?
The code in question was:
(a, b) = re.split("\n\s*\n", text, maxsplit=1)
Thank you for any insights you may have regarding this.
pip install pyre2 -E /tmp/testing
pip install re2 -E /tmp/testing
So, in the worst case (ie, under algorithmic complexity attacks), the NFA implementation is O(m * n), while the complexity of the DFA implementation is - I believe - O(2^m * n)
Also it is technically possible for re2 to (although it doesn't currently do this) add backtracking to its current strategy. If it did this, then it could offer all features of re, but would frequently be much faster. However I would not permanently rule that possibility out.