[3.12] gh-110310: Add a Per-Interpreter XID Registry for Heap Types (… · python/cpython@71c96b5 · GitHub
Skip to content

Commit 71c96b5

Browse files
[3.12] gh-110310: Add a Per-Interpreter XID Registry for Heap Types (gh-110311)
We do the following: * add a per-interpreter XID registry (PyInterpreterState.xidregistry) * put heap types there (keep static types in _PyRuntimeState.xidregistry) * clear the registries during interpreter/runtime finalization * avoid duplicate entries in the registry (when _PyCrossInterpreterData_RegisterClass() is called more than once for a type) * use Py_TYPE() instead of PyObject_Type() in _PyCrossInterpreterData_Lookup() The per-interpreter registry helps preserve isolation between interpreters. This is important when heap types are registered, which is something we haven't been doing yet but I will likely do soon. (cherry-picked from commit 80dc39e)
1 parent 1ea4cb1 commit 71c96b5

3 files changed

Lines changed: 150 additions & 57 deletions

File tree

Include/internal/pycore_interp.h

Lines changed: 29 additions & 15 deletions

Include/internal/pycore_runtime.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ typedef struct pyruntimestate {
111111
tools. */
112112

113113
// XXX Remove this field once we have a tp_* slot.
114-
struct _xidregistry {
115-
PyThread_type_lock mutex;
116-
struct _xidregitem *head;
117-
} xidregistry;
114+
struct _xidregistry xidregistry;
118115

119116
struct _pymem_allocators allocators;
120117
struct _obmalloc_global_state obmalloc;

Python/pystate.c

Lines changed: 120 additions & 38 deletions

0 commit comments

Comments
 (0)