diff options
author | Mark Shannon <mark@hotpy.org> | 2020-01-23 09:25:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-23 09:25:17 (GMT) |
commit | 13bc13960cc83dbd1cb5701d9a59ac9b9144b205 (patch) | |
tree | 582d8286864561b8a29be0491f837c22efd1f07e /Doc/library/dis.rst | |
parent | f9e07e116c32b6dc4561d0bdeb452ccde13b0e7c (diff) | |
download | cpython-13bc13960cc83dbd1cb5701d9a59ac9b9144b205.zip cpython-13bc13960cc83dbd1cb5701d9a59ac9b9144b205.tar.gz cpython-13bc13960cc83dbd1cb5701d9a59ac9b9144b205.tar.bz2 |
bpo-39320: Handle unpacking of *values in compiler (GH-17984)
* Add three new bytecodes: LIST_TO_TUPLE, LIST_EXTEND, SET_UPDATE. Use them to implement star unpacking expressions.
* Remove four bytecodes BUILD_LIST_UNPACK, BUILD_TUPLE_UNPACK, BUILD_SET_UNPACK and BUILD_TUPLE_UNPACK_WITH_CALL opcodes as they are now unused.
* Update magic number and dis.rst for new bytecodes.
Diffstat (limited to 'Doc/library/dis.rst')
-rw-r--r-- | Doc/library/dis.rst | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index aef5c7e..d5d30a0 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -859,40 +859,25 @@ All of the following opcodes use their arguments. .. versionadded:: 3.6 -.. opcode:: BUILD_TUPLE_UNPACK (count) +.. opcode:: LIST_TO_TUPLE - Pops *count* iterables from the stack, joins them in a single tuple, - and pushes the result. Implements iterable unpacking in tuple - displays ``(*x, *y, *z)``. + Pops a list from the stack and pushes a tuple containing the same values. - .. versionadded:: 3.5 - - -.. opcode:: BUILD_TUPLE_UNPACK_WITH_CALL (count) - - This is similar to :opcode:`BUILD_TUPLE_UNPACK`, - but is used for ``f(*x, *y, *z)`` call syntax. The stack item at position - ``count + 1`` should be the corresponding callable ``f``. - - .. versionadded:: 3.6 + .. versionadded:: 3.9 -.. opcode:: BUILD_LIST_UNPACK (count) +.. opcode:: LIST_EXTEND (i) - This is similar to :opcode:`BUILD_TUPLE_UNPACK`, but pushes a list - instead of tuple. Implements iterable unpacking in list - displays ``[*x, *y, *z]``. + Calls ``list.extend(TOS1[-i], TOS)``. Used to build lists. - .. versionadded:: 3.5 + .. versionadded:: 3.9 -.. opcode:: BUILD_SET_UNPACK (count) +.. opcode:: SET_UPDATE - This is similar to :opcode:`BUILD_TUPLE_UNPACK`, but pushes a set - instead of tuple. Implements iterable unpacking in set - displays ``{*x, *y, *z}``. + Calls ``set.update(TOS1[-i], TOS)``. Used to build sets. - .. versionadded:: 3.5 + .. versionadded:: 3.9 .. opcode:: BUILD_MAP_UNPACK (count) @@ -1124,10 +1109,6 @@ All of the following opcodes use their arguments. Calls a callable object with variable set of positional and keyword arguments. If the lowest bit of *flags* is set, the top of the stack contains a mapping object containing additional keyword arguments. - Below that is an iterable object containing positional arguments and - a callable object to call. :opcode:`BUILD_MAP_UNPACK_WITH_CALL` and - :opcode:`BUILD_TUPLE_UNPACK_WITH_CALL` can be used for merging multiple - mapping objects and iterables containing arguments. Before the callable is called, the mapping object and iterable object are each "unpacked" and their contents passed in as keyword and positional arguments respectively. |