@@ -54,11 +54,11 @@ typedef struct _typeobject {
54
54
iternextfunc tp_iternext ;
55
55
56
56
/* Attribute descriptor and subclassing stuff */
57
- struct PyMethodDef * tp_methods ;
58
- struct PyMemberDef * tp_members ;
59
- struct PyGetSetDef * tp_getset ;
57
+ PyMethodDef * tp_methods ;
58
+ PyMemberDef * tp_members ;
59
+ PyGetSetDef * tp_getset ;
60
60
// Strong reference on a heap type, borrowed reference on a static type
61
- struct _typeobject * tp_base ;
61
+ PyTypeObject * tp_base ;
62
62
PyObject * tp_dict ;
63
63
descrgetfunc tp_descr_get ;
64
64
descrsetfunc tp_descr_set ;
@@ -70,17 +70,26 @@ typedef struct _typeobject {
70
70
inquiry tp_is_gc ; /* For PyObject_IS_GC */
71
71
PyObject * tp_bases ;
72
72
PyObject * tp_mro ; /* method resolution order */
73
- PyObject * tp_cache ;
74
- PyObject * tp_subclasses ;
75
- PyObject * tp_weaklist ;
73
+ PyObject * tp_cache ; /* no longer used */
74
+ void * tp_subclasses ; /* for static builtin types this is an index */
75
+ PyObject * tp_weaklist ; /* not used for static builtin types */
76
76
destructor tp_del ;
77
77
78
- /* Type attribute cache version tag. Added in version 2.6 */
78
+ /* Type attribute cache version tag. Added in version 2.6.
79
+ * If zero, the cache is invalid and must be initialized.
80
+ */
79
81
unsigned int tp_version_tag ;
80
82
81
83
destructor tp_finalize ;
82
84
vectorcallfunc tp_vectorcall ;
83
85
84
86
/* bitset of which type-watchers care about this type */
85
87
unsigned char tp_watched ;
88
+
89
+ /* Number of tp_version_tag values used.
90
+ * Set to _Py_ATTR_CACHE_UNUSED if the attribute cache is
91
+ * disabled for this type (e.g. due to custom MRO entries).
92
+ * Otherwise, limited to MAX_VERSIONS_PER_CLASS (defined elsewhere).
93
+ */
94
+ uint16_t tp_versions_used ;
86
95
} PyTypeObject ;
0 commit comments