Title: `sys._clear_internal_caches()` no longer clears the type cache · Issue #155354 · python/cpython · GitHub
Open Graph Title: `sys._clear_internal_caches()` no longer clears the type cache · Issue #155354 · python/cpython
X Title: `sys._clear_internal_caches()` no longer clears the type cache · Issue #155354 · python/cpython
Description: 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...
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/python/cpython/issues/155354
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`sys._clear_internal_caches()` no longer clears the type cache","articleBody":"### Documentation\n\n`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;`.\n\n```python\nimport sys, _testinternalcapi\n\nclass C:\n x = 'v'\n\nC.x # populate the per-type lookup cache\nprint(\"cached: \", _testinternalcapi.type_cache_lookup(C, 'x'))\nsys._clear_type_cache()\nprint(\"after sys._clear_type_cache: \", _testinternalcapi.type_cache_lookup(C, 'x'))\nsys._clear_internal_caches()\nprint(\"after sys._clear_internal_caches:\", _testinternalcapi.type_cache_lookup(C, 'x'))\n```\n\n```\ncached: (1, 'v', 131161)\nafter sys._clear_type_cache: (1, 'v', 131161)\nafter sys._clear_internal_caches: (1, 'v', 131161)\n```\n\nThe 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.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-155378\n* gh-155391\n\u003c!-- /gh-linked-prs -->\n\n","author":{"url":"https://github.com/fedonman","@type":"Person","name":"fedonman"},"datePublished":"2026-08-07T17:23:35Z","url":"https://github.com/python/cpython/issues/155354"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6c91a296-be7f-c67a-c1d0-50ad8d0d4089 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B5D4:29AEE8:3629F55:481DABD:6B020777 |
| html-safe-nonce | f3422f613c3caee434c50a544cd9faf7e16bace84b0b6206d7dd2683d24e3b1f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUQ0OjI5QUVFODozNjI5RjU1OjQ4MURBQkQ6NkIwMjA3NzciLCJ2aXNpdG9yX2lkIjoiMjM0NTM2NzEwMzk1MzA0NTM2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0a50e5a0e0dce12c734575a5eae6af9118aa08a6315d4b476fd1564d8e79826c |
| hovercard-subject-tag | issue:5092484887 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/155354/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d6b3038ff7722d7b18297f6ce167677b1d8a6fe2628641e5aca0d78c84d5ecd/python/cpython/issues/155354 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d6b3038ff7722d7b18297f6ce167677b1d8a6fe2628641e5aca0d78c84d5ecd/python/cpython/issues/155354 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fedonman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width