`sys._clear_internal_caches()` no longer clears the type cache
docs
### 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;`.
```python
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.
1 条评论