`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 封装开始,然后将它们的行为与 Doc/library/sys.rst 以及 Doc/c-api/type.rst 中对 no-op 的描述进行比较。检查这些函数现有的相关测试,以及 GH-150160 的移植说明;当封装、文档和测试一致地反映当前行为时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100