diff options
author | Ken Jin <kenjin4096@gmail.com> | 2022-06-14 13:43:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-14 13:43:28 (GMT) |
commit | 38a7f787d8613b31b81774e780cd9b7e83039d25 (patch) | |
tree | bc72701a3536de0c46f77528345fc4ebec2dc707 /Doc/library/dis.rst | |
parent | a338e106b628601de6f3d57f4a231d2c4fa5f7f1 (diff) | |
download | cpython-38a7f787d8613b31b81774e780cd9b7e83039d25.zip cpython-38a7f787d8613b31b81774e780cd9b7e83039d25.tar.gz cpython-38a7f787d8613b31b81774e780cd9b7e83039d25.tar.bz2 |
GH-93429: Document `LOAD_METHOD` removal (GH-93803)
Diffstat (limited to 'Doc/library/dis.rst')
-rw-r--r-- | Doc/library/dis.rst | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 9163d1a..a6574c4 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -887,7 +887,20 @@ iterations of the loop. .. opcode:: LOAD_ATTR (namei) - Replaces TOS with ``getattr(TOS, co_names[namei])``. + If the low bit of ``namei`` is not set, this replaces TOS with + ``getattr(TOS, co_names[namei>>1])``. + + If the low bit of ``namei`` is set, this will attempt to load a method named + ``co_names[namei>>1]`` from the TOS object. TOS is popped. + This bytecode distinguishes two cases: if TOS has a method with the correct + name, the bytecode pushes the unbound method and TOS. TOS will be used as + the first argument (``self``) by :opcode:`CALL` when calling the + unbound method. Otherwise, ``NULL`` and the object return by the attribute + lookup are pushed. + + .. versionchanged:: 3.11 + If the low bit of ``namei`` is set, then a ``NULL`` or ``self`` is + pushed to the stack before the attribute or unbound method respectively. .. opcode:: COMPARE_OP (opname) @@ -1189,18 +1202,6 @@ iterations of the loop. .. versionadded:: 3.6 -.. opcode:: LOAD_METHOD (namei) - - Loads a method named ``co_names[namei]`` from the TOS object. TOS is popped. - This bytecode distinguishes two cases: if TOS has a method with the correct - name, the bytecode pushes the unbound method and TOS. TOS will be used as - the first argument (``self``) by :opcode:`CALL` when calling the - unbound method. Otherwise, ``NULL`` and the object return by the attribute - lookup are pushed. - - .. versionadded:: 3.7 - - .. opcode:: PUSH_NULL Pushes a ``NULL`` to the stack. |