blob: 9f47899a198e01af913624f5bb3b36fb8bd553a1 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001typedef struct _typeobject {
2 PyObject_VAR_HEAD
Martin Panter78d50332015-08-25 05:06:39 +00003 const char *tp_name; /* For printing, in format "<module>.<name>" */
4 Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
Georg Brandl116aa622007-08-15 14:28:22 +00005
6 /* Methods to implement standard operations */
7
8 destructor tp_dealloc;
9 printfunc tp_print;
10 getattrfunc tp_getattr;
11 setattrfunc tp_setattr;
Yury Selivanovbeaa5092015-08-26 13:03:57 -040012 PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
13 or tp_reserved (Python 3) */
Georg Brandl116aa622007-08-15 14:28:22 +000014 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 */
Martin Panter78d50332015-08-25 05:06:39 +000034 unsigned long tp_flags;
Georg Brandl116aa622007-08-15 14:28:22 +000035
Martin Panter78d50332015-08-25 05:06:39 +000036 const char *tp_doc; /* Documentation string */
Georg Brandl116aa622007-08-15 14:28:22 +000037
Georg Brandl116aa622007-08-15 14:28:22 +000038 /* call function for all accessible objects */
39 traverseproc tp_traverse;
40
41 /* delete references to contained objects */
42 inquiry tp_clear;
43
Georg Brandl116aa622007-08-15 14:28:22 +000044 /* rich comparisons */
45 richcmpfunc tp_richcompare;
46
47 /* weak reference enabler */
Martin Panter78d50332015-08-25 05:06:39 +000048 Py_ssize_t tp_weaklistoffset;
Georg Brandl116aa622007-08-15 14:28:22 +000049
Georg Brandl116aa622007-08-15 14:28:22 +000050 /* 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;
Martin Panter78d50332015-08-25 05:06:39 +000062 Py_ssize_t tp_dictoffset;
Georg Brandl116aa622007-08-15 14:28:22 +000063 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;
Antoine Pitrou796564c2013-07-30 19:59:21 +020073 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
Georg Brandl116aa622007-08-15 14:28:22 +000080} PyTypeObject;