mirror of
https://github.com/python/cpython.git
synced 2026-06-28 03:41:13 +00:00
Character class escapes (``\d``, ``\D``, ``\s``, ``\S``, ``\w`` and ``\W``) that occur outside a character set are now compiled directly to a single CATEGORY opcode instead of being wrapped in an IN block. This removes the IN wrapper (three code words) and an indirect charset() call, and makes such an escape a simple repeatable unit so that, for example, ``\d+`` uses the REPEAT_ONE fast path; a CATEGORY case is added to SRE(count). The transformation preserves behaviour exactly. For category-heavy patterns the compiled byte code is about 20% smaller and matching is up to ~2x faster, with no effect on patterns that do not use bare category escapes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| clinic | ||
| sre.c | ||
| sre.h | ||
| sre_constants.h | ||
| sre_lib.h | ||
| sre_targets.h | ||