Skip to content
Prev Previous commit
Next Next commit
Feedback from code review
  • Loading branch information
brandtbucher committed Sep 8, 2023
commit 21b7fef77782efad37b5febc661b121d788ee520
14 changes: 7 additions & 7 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,8 @@ iterations of the loop.
This bytecode distinguishes two cases: if ``STACK[-1]`` has a method with the
correct name, the bytecode pushes the unbound method and ``STACK[-1]``.
``STACK[-1]`` will be used as the first argument (``self``) by :opcode:`CALL`
or :opcode:`CALL_KW` when calling the unbound method. Otherwise, ``NULL`` and the object returned by
or :opcode:`CALL_KW` when calling the unbound method.
Otherwise, ``NULL`` and the object returned by
the attribute lookup are pushed.

.. versionchanged:: 3.12
Expand Down Expand Up @@ -1394,11 +1395,10 @@ iterations of the loop.
On the stack are (in ascending order):

* The callable
* ``self`` (or ``NULL``)
* ``self`` or ``NULL``
* The remaining positional arguments

``argc`` is the total of the positional arguments, excluding
``self`` when a ``NULL`` is not present.
``argc`` is the total of the positional arguments, excluding ``self``.

``CALL`` pops all arguments and the callable object off the stack,
calls the callable object with those arguments, and pushes the return value
Expand All @@ -1419,13 +1419,13 @@ iterations of the loop.
including one or more named arguments. On the stack are (in ascending order):

* The callable
* ``self`` (or ``NULL``)
* ``self`` or ``NULL``
* The remaining positional arguments
* The named arguments
* A :class:`tuple` of keyword argument names

``argc`` is the total of the positional and named arguments, excluding
``self`` when a ``NULL`` is not present.
``argc`` is the total of the positional and named arguments, excluding ``self``.
The length of the tuple of keyword argument names is the number of named arguments.

``CALL_KW`` pops all arguments, the keyword names, and the callable object
off the stack, calls the callable object with those arguments, and pushes the
Expand Down
7 changes: 2 additions & 5 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2894,13 +2894,9 @@ dummy_func(
CALL_ALLOC_AND_ENTER_INIT,
};

// On entry, the stack is either
// [callable, NULL, arg1, arg2, ...]
// or
// [callable, self, arg1, arg2, ...]
// On exit, the stack is [result].
// When calling Python, inline the call using DISPATCH_INLINED().
inst(CALL, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) {
// oparg counts all of the args, but *not* self:
int total_args = oparg;
if (self_or_null != NULL) {
args--;
Expand Down Expand Up @@ -3514,6 +3510,7 @@ dummy_func(
}

inst(CALL_KW, (callable, self_or_null, args[oparg], kwnames -- res)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this deserves a comment (like CALL) about the stack contents on entry and exit? Or if not, maybe CALL doesn't need it either? (Because it should be clear from the DSL.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'd rather just remove it from both. It's not that complex anymore.

// oparg counts all of the args, but *not* self:
int total_args = oparg;
if (self_or_null != NULL) {
args--;
Expand Down
2 changes: 2 additions & 0 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.