Debian Codegraph @

Doc/includes/typestruct.h

raw
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 PyMethodDef *tp_methods;
58 PyMemberDef *tp_members;
59 PyGetSetDef *tp_getset;
60 // Strong reference on a heap type, borrowed reference on a static type
61 PyTypeObject *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; /* 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 destructor tp_del;
77
78 /* Type attribute cache version tag. Added in version 2.6.
79 * If zero, the cache is invalid and must be initialized.
80 */
81 unsigned int tp_version_tag;
82
83 destructor tp_finalize;
84 vectorcallfunc tp_vectorcall;
85
86 /* bitset of which type-watchers care about this type */
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;
95 } PyTypeObject;