python / python/cpython

Extend and improve `LOAD_COMMON_CONSTANT`

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

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

interpreter-core performance type-feature
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Currently LOAD_COMMON_CONSTANT only loads 7 not-so-common constants and does so fairly inefficiently.

It could be improved in two ways:

  • Add some more constants, especially None, but also "", True, False and -1
  • Make the constants that it does load both statically allocated and immortal to avoid the pointer chasing and incref operation. Only any and all would need changing.

After some consideration, I think it best to leave the common constants table per interpreter, and not statically allocate them.

  • The changes to any and all may be breaking.
  • We also need to handle AssertionError and NotImplementedError will be tricky to make static

They should all be immortal though, and stored as _PyStackRefs not PyObject *s.

Linked PRs
  • gh-148971
  • gh-149625
  • gh-149688

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

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

はじめの一歩

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

調査の方向性

LOAD_COMMON_CONSTANT エントリーポイントから始め、インタープリターごとの共通定数テーブルが値をどのように保存し、返すかを調べます。設計を変更する前にリンクされた PR を確認し、特に _PyStackRef、不滅性、any/all に関する考慮事項を確認します。None、空文字列、True、False、-1 を含む、合意された共通定数が、却下された静的割り当てアプローチを使わずに扱われれば完了です。

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

評価

技術スタック
python
領域
compilers
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

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

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