@@ -75,8 +75,7 @@ the following command can be used to display the disassembly of
75
75
>>> dis.dis(myfunc)
76
76
2 RESUME 0
77
77
<BLANKLINE>
78
- 3 LOAD_GLOBAL 0 (len)
79
- PUSH_NULL
78
+ 3 LOAD_GLOBAL 1 (len + NULL)
80
79
LOAD_FAST 0 (alist)
81
80
CALL 1
82
81
RETURN_VALUE
@@ -208,7 +207,6 @@ Example:
208
207
...
209
208
RESUME
210
209
LOAD_GLOBAL
211
- PUSH_NULL
212
210
LOAD_FAST
213
211
CALL
214
212
RETURN_VALUE
@@ -1217,28 +1215,21 @@ iterations of the loop.
1217
1215
1218
1216
.. opcode :: LOAD_ATTR (namei)
1219
1217
1220
- Replaces ``STACK[-1] `` with ``getattr(STACK[-1], co_names[namei>>1]) ``.
1218
+ If the low bit of ``namei `` is not set, this replaces ``STACK[-1] `` with
1219
+ ``getattr(STACK[-1], co_names[namei>>1]) ``.
1221
1220
1222
- .. versionchanged :: 3.12
1223
- If the low bit of ``namei `` is set, then a ``NULL `` or ``self `` is
1224
- pushed to the stack before the attribute or unbound method respectively.
1225
-
1226
- .. versionchanged :: 3.14
1227
- Reverted change from 3.12. The low bit of ``namei `` has no special meaning.
1228
-
1229
-
1230
- .. opcode :: LOAD_METHOD (namei)
1231
-
1232
- Attempt to load a method named ``co_names[namei>>1] `` from the ``STACK[-1] `` object.
1233
- ``STACK[-1] `` is popped.
1221
+ If the low bit of ``namei `` is set, this will attempt to load a method named
1222
+ ``co_names[namei>>1] `` from the ``STACK[-1] `` object. ``STACK[-1] `` is popped.
1234
1223
This bytecode distinguishes two cases: if ``STACK[-1] `` has a method with the
1235
1224
correct name, the bytecode pushes the unbound method and ``STACK[-1] ``.
1236
1225
``STACK[-1] `` will be used as the first argument (``self ``) by :opcode: `CALL `
1237
1226
or :opcode: `CALL_KW ` when calling the unbound method.
1238
1227
Otherwise, ``NULL `` and the object returned by
1239
1228
the attribute lookup are pushed.
1240
1229
1241
- .. versionadded :: 3.14
1230
+ .. versionchanged :: 3.12
1231
+ If the low bit of ``namei `` is set, then a ``NULL `` or ``self `` is
1232
+ pushed to the stack before the attribute or unbound method respectively.
1242
1233
1243
1234
1244
1235
.. opcode :: LOAD_SUPER_ATTR (namei)
@@ -1935,6 +1926,12 @@ but are replaced by real opcodes or removed before bytecode is generated.
1935
1926
This opcode is now a pseudo-instruction.
1936
1927
1937
1928
1929
+ .. opcode :: LOAD_METHOD
1930
+
1931
+ Optimized unbound method lookup. Emitted as a ``LOAD_ATTR `` opcode
1932
+ with a flag set in the arg.
1933
+
1934
+
1938
1935
.. _opcode_collections :
1939
1936
1940
1937
Opcode collections
0 commit comments