python / python/cpython

`sys._clear_internal_caches()` no longer clears the type cache

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

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

docs
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Documentation

Doc/library/sys.rst says sys._clear_type_cache() clears the internal type cache, and that sys._clear_internal_caches() clears all internal performance-related caches. Neither does any more. Both reach it only through PyType_ClearCache(), which is now just return NEXT_VERSION_TAG(interp) - 1;.

import sys, _testinternalcapi

class C:
    x = 'v'

C.x                                        # populate the per-type lookup cache
print("cached:                          ", _testinternalcapi.type_cache_lookup(C, 'x'))
sys._clear_type_cache()
print("after sys._clear_type_cache:     ", _testinternalcapi.type_cache_lookup(C, 'x'))
sys._clear_internal_caches()
print("after sys._clear_internal_caches:", _testinternalcapi.type_cache_lookup(C, 'x'))
cached:                           (1, 'v', 131161)
after sys._clear_type_cache:      (1, 'v', 131161)
after sys._clear_internal_caches: (1, 'v', 131161)

The C API side is already documented. Doc/c-api/type.rst says the function is now a no-op, and GH-150160 added a matching porting note. The Python wrappers look like the spot that was missed.

Linked PRs
  • gh-155378
  • gh-155391

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

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

はじめの一歩

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

調査の方向性

sys._clear_type_cache() と sys._clear_internal_caches() の Python ラッパーから始め、次にそれらの動作を Doc/library/sys.rst および Doc/c-api/type.rst の no-op の説明と比較します。これらの関数周辺にある既存のテストと、GH-150160 の移植に関する注記を確認してください。ラッパー、ドキュメント、テストが現在の動作を一貫して反映していれば完了です。

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

評価

技術スタック
c, python
領域
backend
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

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

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