Skip to content

gh-152056: Compile single-category character sets to a bare CATEGORY opcode#152057

Open
eendebakpt wants to merge 2 commits into
python:mainfrom
eendebakpt:re-single-category-set
Open

gh-152056: Compile single-category character sets to a bare CATEGORY opcode#152057
eendebakpt wants to merge 2 commits into
python:mainfrom
eendebakpt:re-single-category-set

Conversation

@eendebakpt

@eendebakpt eendebakpt commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

A character set containing exactly one category, e.g. [\d] or [^\s], now compiles to a single CATEGORY opcode (like \d or \S) instead of an IN block. This speeds up matching and reduces the size of the compiled byte code.
See the issue for details.

A character set containing exactly one category, e.g. [\d] or [^\s], now
compiles to a single CATEGORY opcode (like \d or \S) instead of an IN
block.  The negated form maps to the complementary category.  This speeds
up matching and reduces the size of the compiled byte code.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I updated NEWS/What's New to match the previous commit.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33287767 | 📁 Comparing f95141e against main (a46db4f)

  🔍 Preview build  

2 files changed
± whatsnew/3.16.html
± whatsnew/changelog.html

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.

2 participants