`sys._clear_internal_caches()` no longer clears the type cache
還沒有人認領這個 Issue。
- 主要語言
- 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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先從 sys._clear_type_cache() 和 sys._clear_internal_caches() 的 Python wrapper 開始,接著將它們的行為與 Doc/library/sys.rst 以及 Doc/c-api/type.rst 中對 no-op 的描述進行比較。檢查這些函式現有的相關測試,以及 GH-150160 的移植說明;當 wrapper、文件和測試一致地反映目前的行為時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c, python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100