Skip to content

Commit 53fd8f4

Browse files
cdce8peendebakpt
andcommitted
Replace MATCH_CLASS_ISINSTANCE with CALL_INTRINSIC_2
Co-Authored-By: Pieter Eendebak <pieter.eendebak@gmail.com>
1 parent 2307ddd commit 53fd8f4

20 files changed

Lines changed: 487 additions & 697 deletions

Doc/library/dis.rst

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,14 +1755,6 @@ iterations of the loop.
17551755
.. versionadded:: 3.13
17561756

17571757

1758-
.. opcode:: MATCH_CLASS_ISINSTANCE
1759-
1760-
Read match subject ``Stack[-2]`` and the type object ``Stack[-1]`` from stack.
1761-
Pop ``Stack[-1]`` and push ``True`` or ``False`` for the result of :func:`isinstance`.
1762-
1763-
.. versionadded:: 3.15
1764-
1765-
17661758
.. opcode:: MATCH_CLASS (count)
17671759

17681760
``STACK[-1]`` is a tuple of keyword attribute names, ``STACK[-2]`` is the class
@@ -1907,28 +1899,34 @@ iterations of the loop.
19071899

19081900
The operand determines which intrinsic function is called:
19091901

1910-
+----------------------------------------+-----------------------------------+
1911-
| Operand | Description |
1912-
+========================================+===================================+
1913-
| ``INTRINSIC_2_INVALID`` | Not valid |
1914-
+----------------------------------------+-----------------------------------+
1915-
| ``INTRINSIC_PREP_RERAISE_STAR`` | Calculates the |
1916-
| | :exc:`ExceptionGroup` to raise |
1917-
| | from a ``try-except*``. |
1918-
+----------------------------------------+-----------------------------------+
1919-
| ``INTRINSIC_TYPEVAR_WITH_BOUND`` | Creates a :class:`typing.TypeVar` |
1920-
| | with a bound. |
1921-
+----------------------------------------+-----------------------------------+
1922-
| ``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS`` | Creates a |
1923-
| | :class:`typing.TypeVar` with |
1924-
| | constraints. |
1925-
+----------------------------------------+-----------------------------------+
1926-
| ``INTRINSIC_SET_FUNCTION_TYPE_PARAMS`` | Sets the ``__type_params__`` |
1927-
| | attribute of a function. |
1928-
+----------------------------------------+-----------------------------------+
1902+
+----------------------------------------+-----------------------------------------+
1903+
| Operand | Description |
1904+
+========================================+=========================================+
1905+
| ``INTRINSIC_2_INVALID`` | Not valid |
1906+
+----------------------------------------+-----------------------------------------+
1907+
| ``INTRINSIC_PREP_RERAISE_STAR`` | Calculates the |
1908+
| | :exc:`ExceptionGroup` to raise |
1909+
| | from a ``try-except*``. |
1910+
+----------------------------------------+-----------------------------------------+
1911+
| ``INTRINSIC_TYPEVAR_WITH_BOUND`` | Creates a :class:`typing.TypeVar` |
1912+
| | with a bound. |
1913+
+----------------------------------------+-----------------------------------------+
1914+
| ``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS`` | Creates a |
1915+
| | :class:`typing.TypeVar` with |
1916+
| | constraints. |
1917+
+----------------------------------------+-----------------------------------------+
1918+
| ``INTRINSIC_SET_FUNCTION_TYPE_PARAMS`` | Sets the ``__type_params__`` |
1919+
| | attribute of a function. |
1920+
+----------------------------------------+-----------------------------------------+
1921+
| ``INTRINSIC_MATCH_CLASS_ISINSTANCE`` | Do :func:`isinstance` checks for |
1922+
| | :ref:`Class patterns <class-patterns>`. |
1923+
+----------------------------------------+-----------------------------------------+
19291924

19301925
.. versionadded:: 3.12
19311926

1927+
.. versionchanged:: 3.16
1928+
Added ``INTRINSIC_MATCH_CLASS_ISINSTANCE``.
1929+
19321930

19331931
.. opcode:: LOAD_SPECIAL
19341932

Include/internal/pycore_intrinsics.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
#define INTRINSIC_TYPEVAR_WITH_CONSTRAINTS 3
3131
#define INTRINSIC_SET_FUNCTION_TYPE_PARAMS 4
3232
#define INTRINSIC_SET_TYPEPARAM_DEFAULT 5
33+
#define INTRINSIC_MATCH_CLASS_ISINSTANCE 6
3334

34-
#define MAX_INTRINSIC_2 5
35+
#define MAX_INTRINSIC_2 6
3536

3637
typedef PyObject *(*intrinsic_func1)(PyThreadState* tstate, PyObject *value);
3738
typedef PyObject *(*intrinsic_func2)(PyThreadState* tstate, PyObject *value1, PyObject *value2);

Include/internal/pycore_magic_number.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ Known values:
302302
Python 3.16a1 3702 (Replace DELETE_NAME with PUSH_NULL; STORE_NAME)
303303
Python 3.16a1 3703 (Replace DELETE_GLOBAL with PUSH_NULL; STORE_GLOBAL)
304304
Python 3.16a1 3704 (Replace DELETE_ATTR with PUSH_NULL; STORE_ATTR)
305-
Python 3.16a1 3705 (Add MATCH_CLASS_ISINSTANCE opcode)
306305
307306
308307
Python 3.17 will start with 3750
@@ -316,7 +315,7 @@ PC/launcher.c must also be updated.
316315
317316
*/
318317

319-
#define PYC_MAGIC_NUMBER 3705
318+
#define PYC_MAGIC_NUMBER 3704
320319
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
321320
(little-endian) and then appending b'\r\n'. */
322321
#define PYC_MAGIC_NUMBER_TOKEN \

Include/internal/pycore_opcode_metadata.h

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

0 commit comments

Comments
 (0)