Skip to content

gh-153169: Look through marks in the regex alternation quick check#153170

Open
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:sre-branch-peek
Open

gh-153169: Look through marks in the regex alternation quick check#153170
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:sre-branch-peek

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 6, 2026

Copy link
Copy Markdown
Member

The BRANCH quick check skips an alternative whose first literal or character set cannot match the current character, but only when it is the very first op. Look through MARK ops and into a repeat of one item with a nonzero minimum, so alternatives starting with a capturing group or such a repeat are also skipped without entering. The existing checks are performed first and unchanged, so plain alternations are unaffected.

Benchmarks in the issue.

The BRANCH quick check skips an alternative whose first literal or
character set cannot match the current character, but only when it is
the very first op, so alternatives starting with a capturing group or
with a repeat with a nonzero minimum were never skipped.  Look through
MARK ops and into the repeated item.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant