@@ -960,34 +960,38 @@ the more significant byte last.
960
960
961
961
.. opcode :: RAISE_VARARGS (argc)
962
962
963
- Raises an exception. *argc * indicates the number of parameters to the raise
963
+ Raises an exception. *argc * indicates the number of arguments to the raise
964
964
statement, ranging from 0 to 3. The handler will find the traceback as TOS2,
965
965
the parameter as TOS1, and the exception as TOS.
966
966
967
967
968
968
.. opcode :: CALL_FUNCTION (argc)
969
969
970
- Calls a function. The low byte of *argc * indicates the number of positional
971
- parameters, the high byte the number of keyword parameters. On the stack, the
972
- opcode finds the keyword parameters first. For each keyword argument, the
973
- value is on top of the key. Below the keyword parameters, the positional
974
- parameters are on the stack, with the right-most parameter on top. Below the
975
- parameters, the function object to call is on the stack. Pops all function
976
- arguments, and the function itself off the stack, and pushes the return
977
- value.
970
+ Calls a callable object. The low byte of *argc * indicates the number of
971
+ positional arguments, the high byte the number of keyword arguments.
972
+ The stack contains keyword arguments on top (if any), then the positional
973
+ arguments below that (if any), then the callable object to call below that.
974
+ Each keyword argument is represented with two values on the stack:
975
+ the argument's name, and its value, with the argument's value above the
976
+ name on the stack.
977
+ The positional arguments are pushed in the order that they are passed in
978
+ to the callable object, with the right-most positional argument on top.
979
+ ``CALL_FUNCTION `` pops all arguments and the callable object off the stack,
980
+ calls the callable object with those arguments, and pushes the return value
981
+ returned by the callable object.
978
982
979
983
980
984
.. opcode :: MAKE_FUNCTION (argc)
981
985
982
986
Pushes a new function object on the stack. From bottom to top, the consumed
983
987
stack must consist of
984
988
985
- * ``argc & 0xFF `` default argument objects in positional order
989
+ * ``argc & 0xFF `` default argument objects in positional order, for positional parameters
986
990
* ``(argc >> 8) & 0xFF `` pairs of name and default argument, with the name
987
991
just below the object on the stack, for keyword-only parameters
988
992
* ``(argc >> 16) & 0x7FFF `` parameter annotation objects
989
993
* a tuple listing the parameter names for the annotations (only if there are
990
- ony annotation objects)
994
+ any annotation objects)
991
995
* the code associated with the function (at TOS1)
992
996
* the :term: `qualified name ` of the function (at TOS)
993
997
@@ -1020,24 +1024,68 @@ the more significant byte last.
1020
1024
1021
1025
.. opcode :: CALL_FUNCTION_VAR (argc)
1022
1026
1023
- Calls a function. *argc * is interpreted as in :opcode: `CALL_FUNCTION `. The
1024
- top element on the stack contains the variable argument list, followed by
1025
- keyword and positional arguments.
1027
+ Calls a callable object, similarly to :opcode: `CALL_FUNCTION `.
1028
+ *argc * represents the number of keyword and positional
1029
+ arguments, identically to :opcode: `CALL_FUNCTION `.
1030
+ The top of the stack contains keyword arguments (if any), stored
1031
+ identically to :opcode: `CALL_FUNCTION `.
1032
+ Below that
1033
+ is an iterable object containing additional positional arguments.
1034
+ Below that are positional arguments (if any)
1035
+ and a callable object, identically to :opcode: `CALL_FUNCTION `.
1036
+ Before the callable object is called, the iterable object
1037
+ is "unpacked" and its contents are appended to the positional
1038
+ arguments passed in.
1039
+ The iterable object is ignored when computing
1040
+ the value of ``argc ``.
1041
+
1042
+ .. versionchanged :: 3.5
1043
+ In versions 3.0 to 3.4, the iterable object was above
1044
+ the keyword arguments; in 3.5 the iterable object was moved
1045
+ below the keyword arguments.
1046
+
1026
1047
1027
1048
1028
1049
.. opcode :: CALL_FUNCTION_KW (argc)
1029
1050
1030
- Calls a function. *argc * is interpreted as in :opcode: `CALL_FUNCTION `. The
1031
- top element on the stack contains the keyword arguments dictionary, followed
1032
- by explicit keyword and positional arguments.
1051
+ Calls a callable object, similarly to :opcode: `CALL_FUNCTION `.
1052
+ *argc * represents the number of keyword and positional
1053
+ arguments, identically to :opcode: `CALL_FUNCTION `.
1054
+ The top of the stack contains a mapping object containing additional keyword
1055
+ arguments.
1056
+ Below this are keyword arguments (if any), positional arguments (if any),
1057
+ and a callable object, identically to :opcode: `CALL_FUNCTION `.
1058
+ Before the callable is called, the mapping object at the top of the stack is
1059
+ "unpacked" and its contents are appended to the keyword arguments passed in.
1060
+ The mapping object at the top of the stack is ignored when computing
1061
+ the value of ``argc ``.
1033
1062
1034
1063
1035
1064
.. opcode :: CALL_FUNCTION_VAR_KW (argc)
1036
1065
1037
- Calls a function. *argc * is interpreted as in :opcode: `CALL_FUNCTION `. The
1038
- top element on the stack contains the keyword arguments dictionary, followed
1039
- by the variable-arguments tuple, followed by explicit keyword and positional
1040
- arguments.
1066
+ Calls a callable object, similarly to :opcode: `CALL_FUNCTION_VAR ` and
1067
+ :opcode: `CALL_FUNCTION_KW `.
1068
+ *argc * represents the number of keyword and positional
1069
+ arguments, identically to :opcode: `CALL_FUNCTION `.
1070
+ The top of the stack contains a mapping object, as per
1071
+ :opcode: `CALL_FUNCTION_KW `.
1072
+ Below that are keyword arguments (if any), stored
1073
+ identically to :opcode: `CALL_FUNCTION `.
1074
+ Below that
1075
+ is an iterable object containing additional positional arguments.
1076
+ Below that are positional arguments (if any)
1077
+ and a callable object, identically to :opcode: `CALL_FUNCTION `.
1078
+ Before the callable is called, the mapping object and iterable object
1079
+ are each "unpacked" and their contents passed in as keyword and
1080
+ positional arguments respectively,
1081
+ identically to :opcode: `CALL_FUNCTION_VAR ` and :opcode: `CALL_FUNCTION_KW `.
1082
+ The mapping object and iterable object are both ignored when computing
1083
+ the value of ``argc ``.
1084
+
1085
+ .. versionchanged :: 3.5
1086
+ In versions 3.0 to 3.4, the iterable object was above
1087
+ the keyword arguments; in 3.5 the iterable object was moved
1088
+ below the keyword arguments.
1041
1089
1042
1090
1043
1091
.. opcode :: HAVE_ARGUMENT
@@ -1071,7 +1119,7 @@ instructions:
1071
1119
1072
1120
.. data :: hasconst
1073
1121
1074
- Sequence of bytecodes that have a constant parameter .
1122
+ Sequence of bytecodes that access a constant.
1075
1123
1076
1124
1077
1125
.. data :: hasfree
0 commit comments