PyTypeObject

Type objects contain a string containing the type name (to help somewhat in debugging), the allocation parameters (see PyObject_New() and PyObject_NewVar()), and methods for accessing objects of the type. Methods are optional, a nil pointer meaning that particular kind of access is not available for this type. The Py_DECREF() macro uses the tp_dealloc method without checking for a nil pointer; it should always be implemented except if the implementation can guarantee that the reference count will never reach zero (e.g., for statically allocated type objects).

NB: the methods for certain type groups are now contained in separate method blocks.

extern (C)
struct PyTypeObject {}

Members

Mixins

__anonymous
mixin PyObject_VAR_HEAD
Undocumented in source.

Variables

ob_base
PyVarObject ob_base;
Undocumented in source.
ob_refcnt
Py_ssize_t ob_refcnt;
Undocumented in source.
ob_size
Py_ssize_t ob_size;
Undocumented in source.
ob_type
PyTypeObject* ob_type;
Undocumented in source.
tp_alloc
allocfunc tp_alloc;

Attribute descriptor and subclassing stuff

tp_as_async
PyAsyncMethods* tp_as_async;

Methods to implement standard operations

tp_as_buffer
PyBufferProcs* tp_as_buffer;

Functions to access object as input/output buffer

tp_as_mapping
PyMappingMethods* tp_as_mapping;

Method suites for standard classes

tp_as_number
PyNumberMethods* tp_as_number;
tp_as_sequence
PySequenceMethods* tp_as_sequence;

Method suites for standard classes

tp_base
PyTypeObject* tp_base;

Attribute descriptor and subclassing stuff

tp_bases
PyObject* tp_bases;

_

tp_basicsize
Py_ssize_t tp_basicsize;

For allocation

tp_cache
PyObject* tp_cache;

_

tp_call
ternaryfunc tp_call;

More standard operations (here for binary compatibility)

tp_clear
inquiry tp_clear;

delete references to contained objects

tp_compare
cmpfunc tp_compare;
Undocumented in source.
tp_dealloc
destructor tp_dealloc;

Methods to implement standard operations

tp_del
destructor tp_del;

_

tp_descr_get
descrgetfunc tp_descr_get;
tp_descr_set
descrsetfunc tp_descr_set;
tp_dict
PyObject* tp_dict;
tp_dictoffset
Py_ssize_t tp_dictoffset;

Attribute descriptor and subclassing stuff

tp_dictoffset
C_long tp_dictoffset;
Undocumented in source.
tp_doc
const(char)* tp_doc;

Documentation string

tp_finalize
destructor tp_finalize;

Availability: 3.??

tp_flags
C_ulong tp_flags;

Flags to define presence of optional/expanded features

tp_free
freefunc tp_free;

Low-level free-memory routine

tp_getattr
getattrfunc tp_getattr;

Methods to implement standard operations

tp_getattro
getattrofunc tp_getattro;

More standard operations (here for binary compatibility)

tp_getset
PyGetSetDef* tp_getset;

Attribute descriptor and subclassing stuff

tp_hash
hashfunc tp_hash;

More standard operations (here for binary compatibility)

tp_init
initproc tp_init;

Attribute descriptor and subclassing stuff

tp_is_gc
inquiry tp_is_gc;

For PyObject_IS_GC

tp_itemsize
Py_ssize_t tp_itemsize;

For allocation

tp_iter
getiterfunc tp_iter;
tp_iternext
iternextfunc tp_iternext;

Iterators

tp_members
PyMemberDef* tp_members;

Attribute descriptor and subclassing stuff

tp_methods
PyMethodDef* tp_methods;

Attribute descriptor and subclassing stuff

tp_mro
PyObject* tp_mro;

method resolution order

tp_name
const(char)* tp_name;

For printing, in format "<module>.<name>"

tp_new
newfunc tp_new;

Attribute descriptor and subclassing stuff

tp_print
printfunc tp_print;
tp_repr
reprfunc tp_repr;

Methods to implement standard operations

tp_reserved
void* tp_reserved;
Undocumented in source.
tp_richcompare
richcmpfunc tp_richcompare;

rich comparisons

tp_setattr
setattrfunc tp_setattr;

Methods to implement standard operations

tp_setattro
setattrofunc tp_setattro;
tp_str
reprfunc tp_str;

More standard operations (here for binary compatibility)

tp_subclasses
PyObject* tp_subclasses;

_

tp_traverse
traverseproc tp_traverse;

call function for all accessible objects

tp_version_tag
uint tp_version_tag;

Type attribute cache version tag. Added in version 2.6

tp_weaklist
PyObject* tp_weaklist;

_

tp_weaklistoffset
Py_ssize_t tp_weaklistoffset;

weak reference enabler

tp_weaklistoffset
C_long tp_weaklistoffset;
Undocumented in source.

Mixed In Members

From mixin PyObject_VAR_HEAD

__anonymous
mixin PyObject_HEAD
Undocumented in source.
ob_size
Py_ssize_t ob_size;

_

Meta