Skip to content

Optimise keyword arguments in the JIT #150724

@markshannon

Description

@markshannon

Since the JIT traces can see both sides of the call, it can remove the work done to parse and shuffle the arguments during optimization.

For example, calling the function

def foo(a, b): pass

with keyword arguments:

foo(0, b=2, a=1)

requires the tuple ("b", "a") to pushed to the stack after the arguments
and for the CALL_KW_PY instruction to parse and reorder the arguments.

We can work out the reordering required and emit the necessary stack permuting code,
then replace the CALL_KW_PY with a much more effcient CALL_PY_EXACT_ARGS

In the example above:

LOAD_CONSTANT ("b", "a")
CALL_KW_PY 3

can be replaced with

SWAP 2
CALL_PY_EXACT_ARGS 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.16new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetopic-JIT
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions