]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-152056: Compile single-category character sets to a bare CATEGORY opcode (GH-152057)
authorPieter Eendebak <pieter.eendebak@gmail.com>
Wed, 24 Jun 2026 11:09:50 +0000 (13:09 +0200)
committerGitHub <noreply@github.com>
Wed, 24 Jun 2026 11:09:50 +0000 (11:09 +0000)
commit21c4b7359d91b3d78acb04afbe339cbea92bffae
treeb9d10a844fd9e67fbb08eb67b47a4b797144c2fc
parenta46db4f8ba4aa84e0fc5b6986c2388cae2e873ae
gh-152056: Compile single-category character sets to a bare CATEGORY opcode (GH-152057)

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>
Doc/whatsnew/3.16.rst
Lib/re/_parser.py
Misc/NEWS.d/next/Library/2026-06-24-10-30-00.gh-issue-152056.Qk7mZ2.rst [new file with mode: 0644]