@@ -1043,50 +1043,57 @@ All of the following opcodes use their arguments.
1043
1043
1044
1044
.. opcode :: RAISE_VARARGS (argc)
1045
1045
1046
- Raises an exception. *argc * indicates the number of parameters to the raise
1046
+ Raises an exception. *argc * indicates the number of arguments to the raise
1047
1047
statement, ranging from 0 to 3. The handler will find the traceback as TOS2,
1048
1048
the parameter as TOS1, and the exception as TOS.
1049
1049
1050
1050
1051
1051
.. opcode :: CALL_FUNCTION (argc)
1052
1052
1053
- Calls a function. *argc * indicates the number of positional arguments.
1054
- The positional arguments are on the stack, with the right-most argument
1055
- on top. Below the arguments, the function object to call is on the stack.
1056
- Pops all function arguments, and the function itself off the stack, and
1057
- pushes the return value.
1053
+ Calls a callable object with positional arguments.
1054
+ *argc * indicates the number of positional arguments.
1055
+ The top of the stack contains positional arguments, with the right-most
1056
+ argument on top. Below the arguments is a callable object to call.
1057
+ ``CALL_FUNCTION `` pops all arguments and the callable object off the stack,
1058
+ calls the callable object with those arguments, and pushes the return value
1059
+ returned by the callable object.
1058
1060
1059
1061
.. versionchanged :: 3.6
1060
1062
This opcode is used only for calls with positional arguments.
1061
1063
1062
1064
1063
1065
.. opcode :: CALL_FUNCTION_KW (argc)
1064
1066
1065
- Calls a function. *argc * indicates the number of arguments (positional
1066
- and keyword). The top element on the stack contains a tuple of keyword
1067
- argument names. Below the tuple, keyword arguments are on the stack, in
1068
- the order corresponding to the tuple. Below the keyword arguments, the
1069
- positional arguments are on the stack, with the right-most parameter on
1070
- top. Below the arguments, the function object to call is on the stack.
1071
- Pops all function arguments, and the function itself off the stack, and
1072
- pushes the return value.
1067
+ Calls a callable object with positional (if any) and keyword arguments.
1068
+ *argc * indicates the total number of positional and keyword arguments.
1069
+ The top element on the stack contains a tuple of keyword argument names.
1070
+ Below that are keyword arguments in the order corresponding to the tuple.
1071
+ Below that are positional arguments, with the right-most parameter on
1072
+ top. Below the arguments is a callable object to call.
1073
+ ``CALL_FUNCTION_KW `` pops all arguments and the callable object off the stack,
1074
+ calls the callable object with those arguments, and pushes the return value
1075
+ returned by the callable object.
1073
1076
1074
1077
.. versionchanged :: 3.6
1075
1078
Keyword arguments are packed in a tuple instead of a dictionary,
1076
- *argc * indicates the total number of arguments
1079
+ *argc * indicates the total number of arguments.
1077
1080
1078
1081
1079
1082
.. opcode :: CALL_FUNCTION_EX (flags)
1080
1083
1081
- Calls a function. The lowest bit of *flags * indicates whether the
1082
- var-keyword argument is placed at the top of the stack. Below the
1083
- var-keyword argument, the var-positional argument is on the stack.
1084
- Below the arguments, the function object to call is placed.
1085
- Pops all function arguments, and the function itself off the stack, and
1086
- pushes the return value. Note that this opcode pops at most three items
1087
- from the stack. Var-positional and var-keyword arguments are packed
1088
- by :opcode: `BUILD_TUPLE_UNPACK_WITH_CALL ` and
1089
- :opcode: `BUILD_MAP_UNPACK_WITH_CALL `.
1084
+ Calls a callable object with variable set of positional and keyword
1085
+ arguments. If the lowest bit of *flags * is set, the top of the stack
1086
+ contains a mapping object containing additional keyword arguments.
1087
+ Below that is an iterable object containing positional arguments and
1088
+ a callable object to call. :opcode: `BUILD_MAP_UNPACK_WITH_CALL ` and
1089
+ :opcode: `BUILD_TUPLE_UNPACK_WITH_CALL ` can be used for merging multiple
1090
+ mapping objects and iterables containing arguments.
1091
+ Before the callable is called, the mapping object and iterable object
1092
+ are each "unpacked" and their contents passed in as keyword and
1093
+ positional arguments respectively.
1094
+ ``CALL_FUNCTION_EX `` pops all arguments and the callable object off the stack,
1095
+ calls the callable object with those arguments, and pushes the return value
1096
+ returned by the callable object.
1090
1097
1091
1098
.. versionadded :: 3.6
1092
1099
@@ -1096,7 +1103,8 @@ All of the following opcodes use their arguments.
1096
1103
Pushes a new function object on the stack. From bottom to top, the consumed
1097
1104
stack must consist of values if the argument carries a specified flag value
1098
1105
1099
- * ``0x01 `` a tuple of default argument objects in positional order
1106
+ * ``0x01 `` a tuple of default values for positional-only and
1107
+ positional-or-keyword parameters in positional order
1100
1108
* ``0x02 `` a dictionary of keyword-only parameters' default values
1101
1109
* ``0x04 `` an annotation dictionary
1102
1110
* ``0x08 `` a tuple containing cells for free variables, making a closure
@@ -1179,7 +1187,7 @@ instructions:
1179
1187
1180
1188
.. data :: hasconst
1181
1189
1182
- Sequence of bytecodes that have a constant parameter .
1190
+ Sequence of bytecodes that access a constant.
1183
1191
1184
1192
1185
1193
.. data :: hasfree
0 commit comments