3 ms·
The difference is that re2 avoids backtracking in most cases where Python's normal regular expression engine would use it. And by avoiding backtracking, avoids
by btilly 16y ago
The difference is that re2 avoids backtracking in most cases where Python's normal regular expression engine would use it. And by avoiding backtracking, avoids the possibility of exponential slowdowns.
- ori_b 16y agoIsn't that what I just said?
- btilly 16y agoNo. "Doesn't support backtracking" suggests that it doesn't support features that re backtracks for. In fact it does. 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.