Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify oparg & 2 handling
  • Loading branch information
carljm committed Apr 19, 2023
commit e4466a7a0e16393c6bf0c0d2ed7ae03cb0d8b0e1
4 changes: 2 additions & 2 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,8 @@ iterations of the loop.
The low bit of ``namei`` signals to attempt a method load, as with
:opcode:`LOAD_ATTR`.

The second-low bit of ``namei``, if set, means that this was a zero-argument
call to :func:`super`.
The second-low bit of ``namei``, if set, means that this was a two-argument
call to :func:`super` (unset means zero-argument).

.. versionadded:: 3.12

Expand Down
9 changes: 2 additions & 7 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1574,13 +1574,8 @@ dummy_func(
Py_DECREF(self);
}
} else {
PyObject *super;
if (oparg & 2) {
super = PyObject_CallNoArgs(global_super);
} else {
PyObject *stack[] = {class, self};
super = PyObject_Vectorcall(global_super, stack, 2, NULL);
}
PyObject *stack[] = {class, self};
PyObject *super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL);
DECREF_INPUTS();
ERROR_IF(super == NULL, error);
res = PyObject_GetAttr(super, name);
Expand Down
6 changes: 3 additions & 3 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,21 +1053,21 @@ compiler_addop_name(struct compiler_unit *u, location loc,
}
if (opcode == LOAD_SUPER_ATTR) {
arg <<= 2;
arg |= 2;
}
if (opcode == LOAD_SUPER_METHOD) {
opcode = LOAD_SUPER_ATTR;
arg <<= 2;
arg |= 1;
arg |= 3;
}
if (opcode == LOAD_ZERO_SUPER_ATTR) {
opcode = LOAD_SUPER_ATTR;
arg <<= 2;
arg |= 2;
}
if (opcode == LOAD_ZERO_SUPER_METHOD) {
opcode = LOAD_SUPER_ATTR;
arg <<= 2;
arg |= 3;
arg |= 1;
}
return codegen_addop_i(&u->u_instr_sequence, opcode, arg, loc);
}
Expand Down
Loading