Performace of various CPython regexpressions in searching for a substring close to the end of a string
patX_1
: They are all constant-time since the greedy.*
will effectively make the search start at the endpatX_2
: The non-greedy.*?
causes search to start at the beginning of the strings, making this a linear-time operationpatX_3
: With only a plain pattern,re.search
is essentially a non-greedy search, making this also a linear-time operation
patX_2
vspatX_3
: why is it so much (~45x-50x) worse to usepatX_2.search
?