diff options
author | Brandt Bucher <brandtbucher@gmail.com> | 2021-02-26 22:51:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-26 22:51:55 (GMT) |
commit | 145bf269df3530176f6ebeab1324890ef7070bf8 (patch) | |
tree | 4c4928d6250785372171a52be0b7269aa444511b /Doc/library/dis.rst | |
parent | cc02b4f2e810ab524d845daa18bc94df5b092dd8 (diff) | |
download | cpython-145bf269df3530176f6ebeab1324890ef7070bf8.zip cpython-145bf269df3530176f6ebeab1324890ef7070bf8.tar.gz cpython-145bf269df3530176f6ebeab1324890ef7070bf8.tar.bz2 |
bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Talin <viridia@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Diffstat (limited to 'Doc/library/dis.rst')
-rw-r--r-- | Doc/library/dis.rst | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index dad8369..c21a667 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -752,6 +752,49 @@ iterations of the loop. .. versionadded:: 3.2 +.. opcode:: COPY_DICT_WITHOUT_KEYS + + TOS is a tuple of mapping keys, and TOS1 is the match subject. Replace TOS + with a :class:`dict` formed from the items of TOS1, but without any of the + keys in TOS. + + .. versionadded:: 3.10 + + +.. opcode:: GET_LEN + + Push ``len(TOS)`` onto the stack. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_MAPPING + + If TOS is an instance of :class:`collections.abc.Mapping`, push ``True`` onto + the stack. Otherwise, push ``False``. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_SEQUENCE + + If TOS is an instance of :class:`collections.abc.Sequence` and is *not* an + instance of :class:`str`/:class:`bytes`/:class:`bytearray`, push ``True`` + onto the stack. Otherwise, push ``False``. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_KEYS + + TOS is a tuple of mapping keys, and TOS1 is the match subject. If TOS1 + contains all of the keys in TOS, push a :class:`tuple` containing the + corresponding values, followed by ``True``. Otherwise, push ``None``, + followed by ``False``. + + .. versionadded:: 3.10 + + All of the following opcodes use their arguments. .. opcode:: STORE_NAME (namei) @@ -1192,6 +1235,19 @@ All of the following opcodes use their arguments. .. versionadded:: 3.6 +.. opcode:: MATCH_CLASS (count) + + TOS is a tuple of keyword attribute names, TOS1 is the class being matched + against, and TOS2 is the match subject. *count* is the number of positional + sub-patterns. + + Pop TOS. If TOS2 is an instance of TOS1 and has the positional and keyword + attributes required by *count* and TOS, set TOS to ``True`` and TOS1 to a + tuple of extracted attributes. Otherwise, set TOS to ``False``. + + .. versionadded:: 3.10 + + .. opcode:: HAVE_ARGUMENT This is not really an opcode. It identifies the dividing line between |