[New-bugs-announce] [issue46329] Split up the CALL_NO_KW and CALL_KW instructions.

Mark Shannon report at bugs.python.org
Mon Jan 10 07:54:45 EST 2022

New submission from Mark Shannon <mark at hotpy.org>:

Most calls (not those with *args and/or **kwargs) are compiled to the `CALL_NO_KW` and `CALL_KW` instructions, possibly with a `PRECALL_METHOD` prefix.

We want to unify the `CALL_NO_KW` and `CALL_KW` instructions into a single `CALL` instruction and add two new instructions: `PRECALL_FUNCTION` and `KW_NAMES`.
All call sequences would start with `PRECALL_FUNCTION` or `PRECALL_METHOD`. `PRECALL_METHOD` would continue to pair with `LOAD_METHOD` as it does now. `PRECALL_FUNCTION` would effectively be a no-op, but would be needed to set up internal interpreter variables.

`CALL_NO_KW` would become `CALL` and `CALL_KW` would become `KW_NAMES; CALL`.


Specializing calls is an important optimization, but calls are complicated and we want to specialized for both the type of the callable and the shape of the call.

By breaking up calls in this way, we can specialize for the type and for the shape mostly independently.
We can specialize for classes, bound-methods and other objects that ultimately call a Python function in the `PRECALL` instruction and specialize for the shape of the arguments in the `CALL` instruction.

See https://github.com/faster-cpython/ideas/discussions/210 for more rationale.

assignee: Mark.Shannon
messages: 410209
nosy: Mark.Shannon, kj
priority: normal
severity: normal
status: open
title: Split up the CALL_NO_KW and CALL_KW instructions.
type: performance
versions: Python 3.11

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list