You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
re: avoid per-call mark-array allocation for patterns with no capturing groups #150717
Every match, search, or fullmatch on a pattern with no capturing groups allocates capture-group bookkeeping, then frees it without ever reading it. Group-less patterns are common in validation and scanning code, so this runs often.
Examples:
Checking the format of millions of records during an import, e.g. re.match(r"\d{4}-\d{2}-\d{2}", value).
Scanning each log line with re.search(r"ERROR|WARN", line).
Routers and frameworks testing many small patterns per request.
Proposed change: skip that allocation when a pattern has no capturing groups. Patterns with groups stay untouched, and results are identical.
On a local optimized build, re.match and re.search run 11 to 13 percent faster for group-less patterns on short inputs, with no change for patterns that use groups.
Activity
pythongh-150717: Skip mark array allocation for groupless patterns
pythongh-150717: Skip mark array allocation for groupless patterns
gh-150717: Avoid mark-array allocation for groupless regex patterns (G…