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 printfunc tp_print; 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 /* call function for all accessible objects */ 39 traverseproc tp_traverse; 40 41 /* delete references to contained objects */ 42 inquiry tp_clear; 43 44 /* rich comparisons */ 45 richcmpfunc tp_richcompare; 46 47 /* weak reference enabler */ 48 Py_ssize_t tp_weaklistoffset; 49 50 /* Iterators */ 51 getiterfunc tp_iter; 52 iternextfunc tp_iternext; 53 54 /* Attribute descriptor and subclassing stuff */ 55 struct PyMethodDef *tp_methods; 56 struct PyMemberDef *tp_members; 57 struct PyGetSetDef *tp_getset; 58 struct _typeobject *tp_base; 59 PyObject *tp_dict; 60 descrgetfunc tp_descr_get; 61 descrsetfunc tp_descr_set; 62 Py_ssize_t tp_dictoffset; 63 initproc tp_init; 64 allocfunc tp_alloc; 65 newfunc tp_new; 66 freefunc tp_free; /* Low-level free-memory routine */ 67 inquiry tp_is_gc; /* For PyObject_IS_GC */ 68 PyObject *tp_bases; 69 PyObject *tp_mro; /* method resolution order */ 70 PyObject *tp_cache; 71 PyObject *tp_subclasses; 72 PyObject *tp_weaklist; 73 destructor tp_del; 74 75 /* Type attribute cache version tag. Added in version 2.6 */ 76 unsigned int tp_version_tag; 77 78 destructor tp_finalize; 79 80 } PyTypeObject; 81