Optimise keyword arguments in the JIT
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der JIT-Behandlung von CALL_KW_PY und CALL_PY_EXACT_ARGS und verwende das Keyword-Call-Beispiel im Issue, um die erforderliche Umordnung der Argumente zu verstehen. Die Arbeit ist abgeschlossen, wenn der JIT den Keyword-Call durch Code zur Permutation des Stacks und einen Aufruf mit exakten Argumenten ersetzen kann, wobei das gezeigte Aufrufverhalten erhalten bleibt; gh-151389 ist mit dieser Arbeit verknüpft.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers, performance
- Issue-Typ
- Refactoring
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100