mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
This commit is contained in:
parent
3ea7b41b58
commit
908caac52e
8 changed files with 55 additions and 0 deletions
|
|
@ -32,6 +32,24 @@ struct method_cache_entry {
|
|||
|
||||
static struct method_cache_entry method_cache[1 << MCACHE_SIZE_EXP];
|
||||
static unsigned int next_version_tag = 0;
|
||||
static void type_modified(PyTypeObject *);
|
||||
|
||||
unsigned int
|
||||
PyType_ClearCache(void)
|
||||
{
|
||||
Py_ssize_t i;
|
||||
unsigned int cur_version_tag = next_version_tag - 1;
|
||||
|
||||
for (i = 0; i < (1 << MCACHE_SIZE_EXP); i++) {
|
||||
method_cache[i].version = 0;
|
||||
Py_CLEAR(method_cache[i].name);
|
||||
method_cache[i].value = NULL;
|
||||
}
|
||||
next_version_tag = 0;
|
||||
/* mark all version tags as invalid */
|
||||
type_modified(&PyBaseObject_Type);
|
||||
return cur_version_tag;
|
||||
}
|
||||
|
||||
static void
|
||||
type_modified(PyTypeObject *type)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue