diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2023-09-13 17:25:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-13 17:25:45 (GMT) |
commit | 22e65eecaad3f5337862319687047afe9861e1ef (patch) | |
tree | 19089993cd9ec4d1930521c1c3df3cb22b0b9ddc /Doc | |
parent | 987b4bc0870e1e29a88275dc3fa39bf2c3dcc763 (diff) | |
download | cpython-22e65eecaad3f5337862319687047afe9861e1ef.zip cpython-22e65eecaad3f5337862319687047afe9861e1ef.tar.gz cpython-22e65eecaad3f5337862319687047afe9861e1ef.tar.bz2 |
GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/dis.rst | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index d087c7c..b835f1e 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1122,7 +1122,8 @@ iterations of the loop. This bytecode distinguishes two cases: if ``STACK[-1]`` has a method with the correct name, the bytecode pushes the unbound method and ``STACK[-1]``. ``STACK[-1]`` will be used as the first argument (``self``) by :opcode:`CALL` - when calling the unbound method. Otherwise, ``NULL`` and the object returned by + or :opcode:`CALL_KW` when calling the unbound method. + Otherwise, ``NULL`` and the object returned by the attribute lookup are pushed. .. versionchanged:: 3.12 @@ -1390,25 +1391,14 @@ iterations of the loop. .. opcode:: CALL (argc) - Calls a callable object with the number of arguments specified by ``argc``, - including the named arguments specified by the preceding - :opcode:`KW_NAMES`, if any. - On the stack are (in ascending order), either: + Calls a callable object with the number of arguments specified by ``argc``. + On the stack are (in ascending order): - * NULL * The callable - * The positional arguments - * The named arguments - - or: - - * The callable - * ``self`` + * ``self`` or ``NULL`` * The remaining positional arguments - * The named arguments - ``argc`` is the total of the positional and named arguments, excluding - ``self`` when a ``NULL`` is not present. + ``argc`` is the total of the positional arguments, excluding ``self``. ``CALL`` pops all arguments and the callable object off the stack, calls the callable object with those arguments, and pushes the return value @@ -1416,6 +1406,33 @@ iterations of the loop. .. versionadded:: 3.11 + .. versionchanged:: 3.13 + The callable now always appears at the same position on the stack. + + .. versionchanged:: 3.13 + Calls with keyword arguments are now handled by :opcode:`CALL_KW`. + + +.. opcode:: CALL_KW (argc) + + Calls a callable object with the number of arguments specified by ``argc``, + including one or more named arguments. On the stack are (in ascending order): + + * The callable + * ``self`` or ``NULL`` + * The remaining positional arguments + * The named arguments + * A :class:`tuple` of keyword argument names + + ``argc`` is the total of the positional and named arguments, excluding ``self``. + The length of the tuple of keyword argument names is the number of named arguments. + + ``CALL_KW`` pops all arguments, the keyword names, and the callable object + off the stack, calls the callable object with those arguments, and pushes the + return value returned by the callable object. + + .. versionadded:: 3.13 + .. opcode:: CALL_FUNCTION_EX (flags) @@ -1441,15 +1458,6 @@ iterations of the loop. .. versionadded:: 3.11 -.. opcode:: KW_NAMES (consti) - - Prefixes :opcode:`CALL`. - Stores a reference to ``co_consts[consti]`` into an internal variable - for use by :opcode:`CALL`. ``co_consts[consti]`` must be a tuple of strings. - - .. versionadded:: 3.11 - - .. opcode:: MAKE_FUNCTION Pushes a new function object on the stack built from the code object at ``STACK[1]``. |