Skip to content

Commit 070e68a

Browse files
improve the documentation of the LOAD_METHOD and CALL_METHOD (GH-18079)
(cherry picked from commit 8698b34) Co-authored-by: Carl Friedrich Bolz-Tereick <[email protected]>
1 parent c1964e0 commit 070e68a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Doc/library/dis.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,22 +1176,24 @@ All of the following opcodes use their arguments.
11761176

11771177
.. opcode:: LOAD_METHOD (namei)
11781178

1179-
Loads a method named ``co_names[namei]`` from TOS object. TOS is popped and
1180-
method and TOS are pushed when interpreter can call unbound method directly.
1181-
TOS will be used as the first argument (``self``) by :opcode:`CALL_METHOD`.
1182-
Otherwise, ``NULL`` and method is pushed (method is bound method or
1183-
something else).
1179+
Loads a method named ``co_names[namei]`` from the TOS object. TOS is popped.
1180+
This bytecode distinguishes two cases: if TOS has a method with the correct
1181+
name, the bytecode pushes the unbound method and TOS. TOS will be used as
1182+
the first argument (``self``) by :opcode:`CALL_METHOD` when calling the
1183+
unbound method. Otherwise, ``NULL`` and the object return by the attribute
1184+
lookup are pushed.
11841185

11851186
.. versionadded:: 3.7
11861187

11871188

11881189
.. opcode:: CALL_METHOD (argc)
11891190

1190-
Calls a method. *argc* is number of positional arguments.
1191+
Calls a method. *argc* is the number of positional arguments.
11911192
Keyword arguments are not supported. This opcode is designed to be used
11921193
with :opcode:`LOAD_METHOD`. Positional arguments are on top of the stack.
1193-
Below them, two items described in :opcode:`LOAD_METHOD` on the stack.
1194-
All of them are popped and return value is pushed.
1194+
Below them, the two items described in :opcode:`LOAD_METHOD` are on the
1195+
stack (either ``self`` and an unbound method object or ``NULL`` and an
1196+
arbitrary callable). All of them are popped and the return value is pushed.
11951197

11961198
.. versionadded:: 3.7
11971199

0 commit comments

Comments
 (0)