mirror of
https://github.com/python/cpython.git
synced 2025-10-28 17:13:08 +00:00
gh-94673: Clarify About Runtime State Related to Static Builtin Types (gh-117761)
Guido pointed out to me that some details about the per-interpreter state for the builtin types aren't especially clear. I'm addressing that by: * adding a comment explaining that state * adding some asserts to point out the relationship between each index and the interp/global runtime state
This commit is contained in:
parent
30f0643e36
commit
eca53620e3
2 changed files with 43 additions and 1 deletions
|
|
@ -162,9 +162,14 @@ _PyStaticType_GetState(PyInterpreterState *interp, PyTypeObject *self)
|
|||
static void
|
||||
static_builtin_state_init(PyInterpreterState *interp, PyTypeObject *self)
|
||||
{
|
||||
if (!static_builtin_index_is_set(self)) {
|
||||
if (_Py_IsMainInterpreter(interp)) {
|
||||
assert(!static_builtin_index_is_set(self));
|
||||
static_builtin_index_set(self, interp->types.num_builtins_initialized);
|
||||
}
|
||||
else {
|
||||
assert(static_builtin_index_get(self) ==
|
||||
interp->types.num_builtins_initialized);
|
||||
}
|
||||
static_builtin_state *state = static_builtin_state_get(interp, self);
|
||||
|
||||
/* It should only be called once for each builtin type. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue