Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1fc1149
Store the cached def in a wrapping struct rather than directly.
ericsnowcurrently Apr 30, 2024
254e1f1
Pass the cached value around where appropriate.
ericsnowcurrently May 2, 2024
0694318
Pass the cached value to check_singlephase().
ericsnowcurrently May 1, 2024
9ca330b
Add extensions_cache_value helpers.
ericsnowcurrently Apr 30, 2024
7e0c4ee
Add get_cached_m_dict().
ericsnowcurrently Apr 30, 2024
c1c1379
Track ext module origin.
ericsnowcurrently May 1, 2024
8485fb5
Look up core module dicts in get_cached_m_dict().
ericsnowcurrently May 1, 2024
abbddde
Pass m_dict to _extensions_cache_set().
ericsnowcurrently May 1, 2024
12bcd96
Pass m_init to _extensions_cache_set().
ericsnowcurrently May 1, 2024
2d56ada
Add some comments.
ericsnowcurrently May 2, 2024
9c70d53
Use del_cached_m_dict() in set_cached_m_dict().
ericsnowcurrently May 2, 2024
0098057
Add m_init and m_dict fields to extensions_cache_value.
ericsnowcurrently May 1, 2024
57aaba2
Track which interpreter was used to create m_dict.
ericsnowcurrently May 1, 2024
96932eb
Track the interpreter ID.
ericsnowcurrently May 1, 2024
a4cb134
Look up core module dicts in get_cached_m_dict().
ericsnowcurrently May 1, 2024
c4d3be1
Make sure we only set m_dict for non-isolated interpreters.
ericsnowcurrently May 1, 2024
d87584d
Simplify.
ericsnowcurrently May 3, 2024
336d1da
Fix a comment.
ericsnowcurrently May 3, 2024
bd1e134
Separate the def logic from the rest of the extensions cache code.
ericsnowcurrently May 3, 2024
e42e797
Add the per-interpreter cache index to each global cache entry.
ericsnowcurrently May 3, 2024
faa4254
Fix an assert.
ericsnowcurrently May 4, 2024
5276981
Properly sync the cached m_index and the def m_index.
ericsnowcurrently May 3, 2024
f9a2a05
Merge branch 'main' into extensions-cache-better-tracking
ericsnowcurrently May 4, 2024
7d3dbc1
Fix make smelly.
ericsnowcurrently May 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use del_cached_m_dict() in set_cached_m_dict().
  • Loading branch information
ericsnowcurrently committed May 3, 2024
commit 9c70d5317ada2bbc54b3fd47ca88c2ee1af59752
13 changes: 7 additions & 6 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,8 @@ free_extensions_cache_value(struct extensions_cache_value *value)
PyMem_RawFree(value);
}

static void del_cached_m_dict(struct extensions_cache_value *);

static int
set_cached_m_dict(struct extensions_cache_value *value, PyObject *m_dict)
{
Expand Down Expand Up @@ -1001,11 +1003,9 @@ set_cached_m_dict(struct extensions_cache_value *value, PyObject *m_dict)
* Then we'd need to make sure to clear that when the
* runtime is finalized, rather than in
* PyImport_ClearModulesByIndex(). */
PyObject *old = value->def->m_base.m_copy;
if (old != NULL) {
// XXX This should really never happen.
Py_DECREF(old);
}
/* Ideally, the cached dict would always be NULL at this point. */
assert(value->def->m_base.m_copy == NULL || copied != NULL);
del_cached_m_dict(value);

value->def->m_base.m_copy = copied;
return 0;
Expand All @@ -1016,7 +1016,7 @@ del_cached_m_dict(struct extensions_cache_value *value)
{
assert(value != NULL);
if (value->def != NULL) {
Py_XDECREF((PyObject *)value->def->m_base.m_copy);
Py_XDECREF(value->def->m_base.m_copy);
value->def->m_base.m_copy = NULL;
}
}
Expand Down Expand Up @@ -1069,6 +1069,7 @@ update_extensions_cache_value(struct extensions_cache_value *value,
return -1;
}

del_cached_m_dict(value);
*value = temp;
return 0;
}
Expand Down