@@ -548,23 +548,6 @@ struct _types_runtime_state {
548548};
549549
550550
551- // Type attribute lookup cache: speed up attribute and method lookups,
552- // see _PyType_Lookup().
553- struct type_cache_entry {
554- unsigned int version ; // initialized from type->tp_version_tag
555- #ifdef Py_GIL_DISABLED
556- _PySeqLock sequence ;
557- #endif
558- PyObject * name ; // reference to exactly a str or None
559- PyObject * value ; // borrowed reference or NULL
560- };
561-
562- #define MCACHE_SIZE_EXP 12
563-
564- struct type_cache {
565- struct type_cache_entry hashtable [1 << MCACHE_SIZE_EXP ];
566- };
567-
568551typedef struct {
569552 PyTypeObject * type ;
570553 int isbuiltin ;
@@ -579,6 +562,10 @@ typedef struct {
579562 are also some diagnostic uses for the list of weakrefs,
580563 so we still keep it. */
581564 PyObject * tp_weaklist ;
565+ /* Per-interpreter attribute lookup cache (struct type_cache *).
566+ For static builtin types the cache must be per-interpreter
567+ because tp_dict and the values it stores are per-interpreter. */
568+ void * _tp_cache ;
582569} managed_static_type_state ;
583570
584571#define TYPE_VERSION_CACHE_SIZE (1<<12) /* Must be a power of 2 */
@@ -589,8 +576,6 @@ struct types_state {
589576 where all those lower numbers are used for core static types. */
590577 unsigned int next_version_tag ;
591578
592- struct type_cache type_cache ;
593-
594579 /* Every static builtin type is initialized for each interpreter
595580 during its own initialization, including for the main interpreter
596581 during global runtime initialization. This is done by calling
0 commit comments