Skip to content

Commit 4b2a2a4

Browse files
ilevkivskyibrettcannon
authored andcommitted
bpo-28810: Document changes to CALL_FUNCTION opcodes (pythonGH-250)
1 parent 7400254 commit 4b2a2a4

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

Doc/library/dis.rst

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,21 +1009,52 @@ All of the following opcodes use their arguments.
10091009

10101010
.. opcode:: CALL_FUNCTION (argc)
10111011

1012-
Calls a function. The low byte of *argc* indicates the number of positional
1013-
parameters, the high byte the number of keyword parameters. On the stack, the
1014-
opcode finds the keyword parameters first. For each keyword argument, the
1015-
value is on top of the key. Below the keyword parameters, the positional
1016-
parameters are on the stack, with the right-most parameter on top. Below the
1017-
parameters, the function object to call is on the stack. Pops all function
1018-
arguments, and the function itself off the stack, and pushes the return
1019-
value.
1012+
Calls a function. *argc* indicates the number of positional arguments.
1013+
The positional arguments are on the stack, with the right-most argument
1014+
on top. Below the arguments, the function object to call is on the stack.
1015+
Pops all function arguments, and the function itself off the stack, and
1016+
pushes the return value.
1017+
1018+
.. versionchanged:: 3.6
1019+
This opcode is used only for calls with positional arguments.
1020+
1021+
1022+
.. opcode:: CALL_FUNCTION_KW (argc)
1023+
1024+
Calls a function. *argc* indicates the number of arguments (positional
1025+
and keyword). The top element on the stack contains a tuple of keyword
1026+
argument names. Below the tuple, keyword arguments are on the stack, in
1027+
the order corresponding to the tuple. Below the keyword arguments, the
1028+
positional arguments are on the stack, with the right-most parameter on
1029+
top. Below the arguments, the function object to call is on the stack.
1030+
Pops all function arguments, and the function itself off the stack, and
1031+
pushes the return value.
1032+
1033+
.. versionchanged:: 3.6
1034+
Keyword arguments are packed in a tuple instead of a dictionary,
1035+
*argc* indicates the total number of arguments
1036+
1037+
1038+
.. opcode:: CALL_FUNCTION_EX (flags)
1039+
1040+
Calls a function. The lowest bit of *flags* indicates whether the
1041+
var-keyword argument is placed at the top of the stack. Below the
1042+
var-keyword argument, the var-positional argument is on the stack.
1043+
Below the arguments, the function object to call is placed.
1044+
Pops all function arguments, and the function itself off the stack, and
1045+
pushes the return value. Note that this opcode pops at most three items
1046+
from the stack. Var-positional and var-keyword arguments are packed
1047+
by :opcode:`BUILD_MAP_UNPACK_WITH_CALL` and
1048+
:opcode:`BUILD_MAP_UNPACK_WITH_CALL`.
1049+
1050+
.. versionadded:: 3.6
10201051

10211052

10221053
.. opcode:: LOAD_METHOD (namei)
10231054

10241055
Loads a method named ``co_names[namei]`` from TOS object. TOS is popped and
10251056
method and TOS are pushed when interpreter can call unbound method directly.
1026-
TOS will be uesd as the first argument (``self``) by :opcode:`CALL_METHOD`.
1057+
TOS will be used as the first argument (``self``) by :opcode:`CALL_METHOD`.
10271058
Otherwise, ``NULL`` and method is pushed (method is bound method or
10281059
something else).
10291060

@@ -1071,28 +1102,6 @@ All of the following opcodes use their arguments.
10711102
two most-significant bytes.
10721103

10731104

1074-
.. opcode:: CALL_FUNCTION_VAR (argc)
1075-
1076-
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
1077-
top element on the stack contains the variable argument list, followed by
1078-
keyword and positional arguments.
1079-
1080-
1081-
.. opcode:: CALL_FUNCTION_KW (argc)
1082-
1083-
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
1084-
top element on the stack contains the keyword arguments dictionary, followed
1085-
by explicit keyword and positional arguments.
1086-
1087-
1088-
.. opcode:: CALL_FUNCTION_VAR_KW (argc)
1089-
1090-
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
1091-
top element on the stack contains the keyword arguments dictionary, followed
1092-
by the variable-arguments tuple, followed by explicit keyword and positional
1093-
arguments.
1094-
1095-
10961105
.. opcode:: FORMAT_VALUE (flags)
10971106

10981107
Used for implementing formatted literal strings (f-strings). Pops

0 commit comments

Comments
 (0)