[Python-ideas] Bytecode for calling function with keyword arguments
storchaka at gmail.com
Thu Apr 21 13:28:39 EDT 2016
On 21.04.16 19:00, Chris Angelico wrote:
> On Fri, Apr 22, 2016 at 1:52 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:
>> 2. Since the number of keyword arguments is obtained from tuple's size, new
>> CALL_FUNCTION opcode needs only the number of positional arguments. It's
>> argument is simpler and needs less bits (important for wordcode).
> What about calls that don't include any keyword arguments? Currently,
> no pushing is done. Will you have two opcodes, one if there are kwargs
> and one if there are not?
Yes, we need either two opcodes, or a falg in the argument. I prefer the
first approach to keep the argument short and simple.
> Also: How does this interact with **dict calls?
For now we have separate opcode for calls with **kwargs. We will have
corresponding opcode with new way to provide keyword arguments.
Instead of 4 current opcodes we will need at most 8 new opcodes. May be
less, because calls with *args or **kwargs is less performance critical,
we can pack arguments in a tuple and a dict by separate opcodes and call
a function just with a tuple and a dict.
More information about the Python-ideas