bpo-26213: Document _UNPACK bytecodes and BUILD_MAP changes (GH-441) · python/cpython@4d0630d
@@ -765,8 +765,59 @@ the more significant byte last.
765765766766.. opcode:: BUILD_MAP (count)
767767768- Pushes a new dictionary object onto the stack. The dictionary is pre-sized
769- to hold *count* entries.
768+ Pushes a new dictionary object onto the stack. Pops ``2 * count`` items
769+ so that the dictionary holds *count* entries:
770+ ``{..., TOS3: TOS2, TOS1: TOS}``.
771+772+ .. versionchanged:: 3.5
773+ The dictionary is created from stack items instead of creating an
774+ empty dictionary pre-sized to hold *count* items.
775+776+777+.. opcode:: BUILD_TUPLE_UNPACK (count)
778+779+ Pops *count* iterables from the stack, joins them in a single tuple,
780+ and pushes the result. Implements iterable unpacking in tuple
781+ displays ``(*x, *y, *z)``.
782+783+ .. versionadded:: 3.5
784+785+786+.. opcode:: BUILD_LIST_UNPACK (count)
787+788+ This is similar to :opcode:`BUILD_TUPLE_UNPACK`, but pushes a list
789+ instead of tuple. Implements iterable unpacking in list
790+ displays ``[*x, *y, *z]``.
791+792+ .. versionadded:: 3.5
793+794+795+.. opcode:: BUILD_SET_UNPACK (count)
796+797+ This is similar to :opcode:`BUILD_TUPLE_UNPACK`, but pushes a set
798+ instead of tuple. Implements iterable unpacking in set
799+ displays ``{*x, *y, *z}``.
800+801+ .. versionadded:: 3.5
802+803+804+.. opcode:: BUILD_MAP_UNPACK (count)
805+806+ Pops *count* mappings from the stack, merges them into a single dictionary,
807+ and pushes the result. Implements dictionary unpacking in dictionary
808+ displays ``{**x, **y, **z}``.
809+810+ .. versionadded:: 3.5
811+812+813+.. opcode:: BUILD_MAP_UNPACK_WITH_CALL (oparg)
814+815+ This is similar to :opcode:`BUILD_MAP_UNPACK`,
816+ but is used for ``f(**x, **y, **z)`` call syntax. The lowest byte of
817+ *oparg* is the count of mappings, the relative position of the
818+ corresponding callable ``f`` is encoded in the second byte of *oparg*.
819+820+ .. versionadded:: 3.5
770821771822772823.. opcode:: LOAD_ATTR (namei)