@@ -36,11 +36,12 @@ the following command can be used to display the disassembly of
36
36
>>> dis.dis(myfunc)
37
37
1 0 RESUME 0
38
38
39
- 2 2 LOAD_GLOBAL 0 (len)
40
- 4 LOAD_FAST 0 (alist)
41
- 6 PRECALL_FUNCTION 1
42
- 8 CALL 0
43
- 10 RETURN_VALUE
39
+ 2 2 PUSH_NULL
40
+ 4 LOAD_GLOBAL 0 (len)
41
+ 6 LOAD_FAST 0 (alist)
42
+ 8 PRECALL 1
43
+ 10 CALL 1
44
+ 12 RETURN_VALUE
44
45
45
46
(The "2" is a line number).
46
47
@@ -106,9 +107,10 @@ Example::
106
107
... print(instr.opname)
107
108
...
108
109
RESUME
110
+ PUSH_NULL
109
111
LOAD_GLOBAL
110
112
LOAD_FAST
111
- PRECALL_FUNCTION
113
+ PRECALL
112
114
CALL
113
115
RETURN_VALUE
114
116
@@ -1063,18 +1065,28 @@ iterations of the loop.
1063
1065
with ``__cause__ `` set to ``TOS ``)
1064
1066
1065
1067
1066
- .. opcode :: CALL (named )
1068
+ .. opcode :: CALL (argc )
1067
1069
1068
- Calls a callable object with the number of positional arguments specified by
1069
- the preceding :opcode: `PRECALL_FUNCTION ` or :opcode: `PRECALL_METHOD ` and
1070
- the named arguments specified by the preceding :opcode: `KW_NAMES `, if any.
1071
- *named * indicates the number of named arguments.
1072
- On the stack are (in ascending order):
1070
+ Calls a callable object with the number of arguments specified by ``argc ``,
1071
+ including the named arguments specified by the preceding
1072
+ :opcode: `KW_NAMES `, if any.
1073
+ On the stack are (in ascending order), either:
1073
1074
1075
+ * NULL
1074
1076
* The callable
1075
1077
* The positional arguments
1076
1078
* The named arguments
1077
1079
1080
+ or:
1081
+
1082
+ * The callable
1083
+ * ``self ``
1084
+ * The remaining positional arguments
1085
+ * The named arguments
1086
+
1087
+ ``argc `` is the total of the positional and named arguments, excluding
1088
+ ``self `` when a ``NULL `` is not present.
1089
+
1078
1090
``CALL `` pops all arguments and the callable object off the stack,
1079
1091
calls the callable object with those arguments, and pushes the return value
1080
1092
returned by the callable object.
@@ -1102,33 +1114,34 @@ iterations of the loop.
1102
1114
Loads a method named ``co_names[namei] `` from the TOS object. TOS is popped.
1103
1115
This bytecode distinguishes two cases: if TOS has a method with the correct
1104
1116
name, the bytecode pushes the unbound method and TOS. TOS will be used as
1105
- the first argument (``self ``) by :opcode: `PRECALL_METHOD ` when calling the
1117
+ the first argument (``self ``) by :opcode: `CALL ` when calling the
1106
1118
unbound method. Otherwise, ``NULL `` and the object return by the attribute
1107
1119
lookup are pushed.
1108
1120
1109
1121
.. versionadded :: 3.7
1110
1122
1111
1123
1112
- .. opcode :: PRECALL_METHOD (argc)
1124
+ .. opcode :: PRECALL (argc)
1113
1125
1114
- Prefixes :opcode: `CALL ` (possibly with an intervening ``KW_NAMES ``).
1115
- This opcode is designed to be used with :opcode: `LOAD_METHOD `.
1116
- Sets internal variables, so that :opcode: `CALL `
1117
- clean up after :opcode: `LOAD_METHOD ` correctly.
1126
+ Prefixes :opcode: `CALL `. Logically this is a no op.
1127
+ It exists to enable effective specialization of calls.
1128
+ ``argc `` is the number of arguments as described in :opcode: `CALL `.
1118
1129
1119
1130
.. versionadded :: 3.11
1120
1131
1121
1132
1122
- .. opcode :: PRECALL_FUNCTION (args)
1133
+ .. opcode :: PUSH_NULL
1123
1134
1124
- Prefixes :opcode: `CALL ` (possibly with an intervening ``KW_NAMES ``).
1125
- Sets internal variables, so that :opcode: `CALL ` can execute correctly.
1135
+ Pushes a ``NULL `` to the stack.
1136
+ Used in the call sequence to match the ``NULL `` pushed by
1137
+ :opcode: `LOAD_METHOD ` for non-method calls.
1126
1138
1127
1139
.. versionadded :: 3.11
1128
1140
1129
1141
1130
1142
.. opcode :: KW_NAMES (i)
1131
1143
1144
+ Prefixes :opcode: `PRECALL `.
1132
1145
Stores a reference to ``co_consts[consti] `` into an internal variable
1133
1146
for use by :opcode: `CALL `. ``co_consts[consti] `` must be a tuple of strings.
1134
1147
0 commit comments