1 typedef struct _typeobject { 2 PyObject_VAR_HEAD 3 const char *tp_name; /* For printing, in format "<module>.<name>" */ 4 Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */ 5 6 /* Methods to implement standard operations */ 7 8 destructor tp_dealloc; 9 Py_ssize_t tp_vectorcall_offset; 10 getattrfunc tp_getattr; 11 setattrfunc tp_setattr; 12 PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2) 13 or tp_reserved (Python 3) */ 14 reprfunc tp_repr; 15 16 /* Method suites for standard classes */ 17 18 PyNumberMethods *tp_as_number; 19 PySequenceMethods *tp_as_sequence; 20 PyMappingMethods *tp_as_mapping; 21 22 /* More standard operations (here for binary compatibility) */ 23 24 hashfunc tp_hash; 25 ternaryfunc tp_call; 26 reprfunc tp_str; 27 getattrofunc tp_getattro; 28 setattrofunc tp_setattro; 29 30 /* Functions to access object as input/output buffer */ 31 PyBufferProcs *tp_as_buffer; 32 33 /* Flags to define presence of optional/expanded features */ 34 unsigned long tp_flags; 35 36 const char *tp_doc; /* Documentation string */ 37 38 /* Assigned meaning in release 2.0 */ 39 /* call function for all accessible objects */ 40 traverseproc tp_traverse; 41 42 /* delete references to contained objects */ 43 inquiry tp_clear; 44 45 /* Assigned meaning in release 2.1 */ 46 /* rich comparisons */ 47 richcmpfunc tp_richcompare; 48 49 /* weak reference enabler */ 50 Py_ssize_t tp_weaklistoffset; 51 52 /* Iterators */ 53 getiterfunc tp_iter; 54 iternextfunc tp_iternext; 55 56 /* Attribute descriptor and subclassing stuff */ 57 struct PyMethodDef *tp_methods; 58 struct PyMemberDef *tp_members; 59 struct PyGetSetDef *tp_getset; 60 // Strong reference on a heap type, borrowed reference on a static type 61 struct _typeobject *tp_base; 62 PyObject *tp_dict; 63 descrgetfunc tp_descr_get; 64 descrsetfunc tp_descr_set; 65 Py_ssize_t tp_dictoffset; 66 initproc tp_init; 67 allocfunc tp_alloc; 68 newfunc tp_new; 69 freefunc tp_free; /* Low-level free-memory routine */ 70 inquiry tp_is_gc; /* For PyObject_IS_GC */ 71 PyObject *tp_bases; 72 PyObject *tp_mro; /* method resolution order */ 73 PyObject *tp_cache; 74 PyObject *tp_subclasses; 75 PyObject *tp_weaklist; 76 destructor tp_del; 77 78 /* Type attribute cache version tag. Added in version 2.6 */ 79 unsigned int tp_version_tag; 80 81 destructor tp_finalize; 82 vectorcallfunc tp_vectorcall; 83 } PyTypeObject; 84