8
.. index:: object: type
11
.. c:type:: PyTypeObject
13
The C structure of the objects used to describe built-in types.
16
.. c:var:: PyObject* PyType_Type
18
.. index:: single: TypeType (in module types)
20
This is the type object for type objects; it is the same object as ``type`` and
21
``types.TypeType`` in the Python layer.
24
.. c:function:: int PyType_Check(PyObject *o)
26
Return true if the object *o* is a type object, including instances of types
27
derived from the standard type object. Return false in all other cases.
30
.. c:function:: int PyType_CheckExact(PyObject *o)
32
Return true if the object *o* is a type object, but not a subtype of the
33
standard type object. Return false in all other cases.
38
.. c:function:: unsigned int PyType_ClearCache()
40
Clear the internal lookup cache. Return the current version tag.
45
.. c:function:: void PyType_Modified(PyTypeObject *type)
47
Invalidate the internal lookup cache for the type and all of its
48
subtypes. This function must be called after any manual
49
modification of the attributes or base classes of the type.
54
.. c:function:: int PyType_HasFeature(PyObject *o, int feature)
56
Return true if the type object *o* sets the feature *feature*. Type features
57
are denoted by single bit flags.
60
.. c:function:: int PyType_IS_GC(PyObject *o)
62
Return true if the type object includes support for the cycle detector; this
63
tests the type flag :const:`Py_TPFLAGS_HAVE_GC`.
68
.. c:function:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
70
Return true if *a* is a subtype of *b*.
74
This function only checks for actual subtypes, which means that
75
:meth:`~class.__subclasscheck__` is not called on *b*. Call
76
:c:func:`PyObject_IsSubclass` to do the same check that :func:`issubclass`
80
.. c:function:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
84
.. versionchanged:: 2.5
85
This function used an :c:type:`int` type for *nitems*. This might require
86
changes in your code for properly supporting 64-bit systems.
89
.. c:function:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
94
.. c:function:: int PyType_Ready(PyTypeObject *type)
96
Finalize a type object. This should be called on all type objects to finish
97
their initialization. This function is responsible for adding inherited slots
98
from a type's base class. Return ``0`` on success, or return ``-1`` and sets an
101
.. versionadded:: 2.2