Skip to content

Commit 8cfaa01

Browse files
committed
gh-138912: Add fast path for match class patterns without sub-patterns
1 parent 75d4839 commit 8cfaa01

File tree

18 files changed

+669
-435
lines changed

18 files changed

+669
-435
lines changed

Doc/library/dis.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,14 @@ iterations of the loop.
17521752
.. versionadded:: 3.13
17531753

17541754

1755+
.. opcode:: MATCH_CLASS_ISINSTANCE
1756+
1757+
Read match subject ``Stack[-2]`` and the type object ``Stack[-1]`` from stack.
1758+
Pop ``Stack[-1]`` and push ``True`` or ``False`` for the result of :func:`isinstance`.
1759+
1760+
.. versionadded:: 3.15
1761+
1762+
17551763
.. opcode:: MATCH_CLASS (count)
17561764

17571765
``STACK[-1]`` is a tuple of keyword attribute names, ``STACK[-2]`` is the class

Include/internal/pycore_magic_number.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ Known values:
292292
Python 3.15a4 3659 (Add CALL_FUNCTION_EX specialization)
293293
Python 3.15a4 3660 (Change generator preamble code)
294294
Python 3.15a4 3661 (Lazy imports IMPORT_NAME opcode changes)
295+
Python 3.15a7 3662 (Add MATCH_CLASS_ISINSTANCE opcode)
295296
296297
297298
Python 3.16 will start with 3700
@@ -305,7 +306,7 @@ PC/launcher.c must also be updated.
305306
306307
*/
307308

308-
#define PYC_MAGIC_NUMBER 3661
309+
#define PYC_MAGIC_NUMBER 3662
309310
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
310311
(little-endian) and then appending b'\r\n'. */
311312
#define PYC_MAGIC_NUMBER_TOKEN \

Include/internal/pycore_opcode_metadata.h

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)