Skip to content

Commit bbcc0df

Browse files
committed
Document new LOAD_METHOD instruction. Update docs for LOAD_ATTR
1 parent 7806d43 commit bbcc0df

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Doc/library/dis.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,21 +1215,28 @@ iterations of the loop.
12151215

12161216
.. opcode:: LOAD_ATTR (namei)
12171217

1218-
If the low bit of ``namei`` is not set, this replaces ``STACK[-1]`` with
1219-
``getattr(STACK[-1], co_names[namei>>1])``.
1218+
Replaces ``STACK[-1]`` with ``getattr(STACK[-1], co_names[namei>>1])``.
12201219

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.
1220+
.. versionchanged:: 3.12
1221+
If the low bit of ``namei`` is set, then a ``NULL`` or ``self`` is
1222+
pushed to the stack before the attribute or unbound method respectively.
1223+
1224+
.. versionchanged:: 3.14
1225+
Reverted change from 3.12. The low bit of ``namei`` has no special meaning.
1226+
1227+
1228+
.. opcode:: LOAD_METHOD (namei)
1229+
1230+
Attempt to load a method named ``co_names[namei>>1]`` from the ``STACK[-1]`` object.
1231+
``STACK[-1]`` is popped.
12231232
This bytecode distinguishes two cases: if ``STACK[-1]`` has a method with the
12241233
correct name, the bytecode pushes the unbound method and ``STACK[-1]``.
12251234
``STACK[-1]`` will be used as the first argument (``self``) by :opcode:`CALL`
12261235
or :opcode:`CALL_KW` when calling the unbound method.
12271236
Otherwise, ``NULL`` and the object returned by
12281237
the attribute lookup are pushed.
12291238

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.
1239+
.. versionadded:: 3.14
12331240

12341241

12351242
.. opcode:: LOAD_SUPER_ATTR (namei)

0 commit comments

Comments
 (0)