Optimise keyword arguments in the JIT
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
Linked PRs
- gh-151389
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the JIT handling of CALL_KW_PY and CALL_PY_EXACT_ARGS, using the keyword-call example in the issue to understand the required argument reordering. Done means the JIT can replace the keyword call with stack-permuting code and an exact-argument call while preserving the shown call behavior; gh-151389 is linked to this work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100