CALL_FUNCTION_EX argument passing routine can be improved for vectorcalls
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
do_call_core、_PyVectorcall_Call、_PyStack_UnpackDict、_PyEval_Vector、_PyEvalFramePushAndInit、initialize_locals を通る引数の流れを追跡します。まず、CALL_FUNCTION_EX が vectorcall の Python 関数に到達する仕組みと、各境界で所有権がどのように扱われるかを理解します。中間の C 配列と tuple/dict の再作成を経路から排除しつつ、引数の正しい所有権と動作を維持できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
While working on https://github.com/python/cpython/issues/95126, I noticed that CALL_FUNCTION_EX for vectorcall Python functions is extremely wasteful. These are its steps:
CALL_FUNCTION_EXcallsdo_call_corewith aargstuple andkwargsdict.- Eventually it's detected that the function supports vectorcall, and it calls
_PyVectorcall_Call. This calls_PyStack_UnpackDict, which unpacks theargstuple andkwargsdict into a C array. - This C array is passed to the vectorcall function. Eventually calling
_PyEval_Vector. _PyEval_Vectorcalls_PyEvalFramePushAndInit, which sees that there's complex args, and recreates the tuple and args dict ininitialize_localsfrom the C array.- Frame is pushed and evaluated, then popped. End.
We shouldn't even be converting the arguments to a C array just to vectorcall. We should instead directly transfer ownership of args tuple and kwds dict because that would be significantly faster in this case (and save us the tuple and dict recreation dance).
CC @markshannon and @brandtbucher .
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 558
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/cpython のほかの issue
-
docs pending
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
stdlib type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
stdlib type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
build type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
stdlib topic-email type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
bancolombia/sentinel#23 ·
-
test md オープンCI
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
langchain-ai/deepagents#6450 ·
-
bug client
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100