Specialized `match_keys` for exact dictionary type

オープン
#93,714 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
c, python
領域
compilers

調査の方向性

ceval.c の match_keys から始め、現在の structural pattern matching が mapping のキーと完全一致する dict 型をどのように処理しているかを調べてください。既存の lookup セマンティクスを含む観測可能な動作を変更せずに、完全一致する dict が専用パスを使用するようになれば変更は完了です。利用可能であれば、関連するマイクロベンチマークを比較してください。

索引モデルが issue の本文から書いたものです。

説明

3.13 interpreter-core performance type-feature

Feature or enhancement

I think it's probably worthwhile to write a specialized version of match_keys (for structural pattern matching of mappings) for exact dictionary types

Pitch

The most common mapping type is almost certainly the built-in dict. The match_keys function in ceval.c could be specialized to handle this type. Doing so would allow you to skip the dummy object, and replace the get call with PyDict_GetItemWithError. I don't think this should change the observable behaviour at all for exact dict

I'm in the process of reimplementing structural pattern matching on Cython, and this change gives ~2x optimization of some microbenchmarks.

If this change is deemed desirable I'm happy to implement it myself.

Previous discussion

Not aware of any

主要言語
Python
スター
77.2k
フォーク
36k
平均マージ
1日 9時間
マージ済み PR(30日)
558

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python/cpython のほかの issue

python/cpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。