PageRenderTime 38ms CodeModel.GetById 30ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/Doc/c-api/type.rst

http://unladen-swallow.googlecode.com/
ReStructuredText | 96 lines | 49 code | 47 blank | 0 comment | 0 complexity | dc49b6bc221aaec840c6f6cb4af02fa4 MD5 | raw file
 1.. highlightlang:: c
 2
 3.. _typeobjects:
 4
 5Type Objects
 6------------
 7
 8.. index:: object: type
 9
10
11.. ctype:: PyTypeObject
12
13   The C structure of the objects used to describe built-in types.
14
15
16.. cvar:: PyObject* PyType_Type
17
18   .. index:: single: TypeType (in module types)
19
20   This is the type object for type objects; it is the same object as ``type`` and
21   ``types.TypeType`` in the Python layer.
22
23
24.. cfunction:: int PyType_Check(PyObject *o)
25
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.
28
29
30.. cfunction:: int PyType_CheckExact(PyObject *o)
31
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.
34
35   .. versionadded:: 2.2
36
37
38.. cfunction:: unsigned int PyType_ClearCache(void)
39
40   Clear the internal lookup cache. Return the current version tag.
41
42   .. versionadded:: 2.6
43
44
45.. cfunction:: void PyType_Modified(PyTypeObject *type)
46
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.
50
51   .. versionadded:: 2.6
52
53
54.. cfunction:: int PyType_HasFeature(PyObject *o, int feature)
55
56   Return true if the type object *o* sets the feature *feature*.  Type features
57   are denoted by single bit flags.
58
59
60.. cfunction:: int PyType_IS_GC(PyObject *o)
61
62   Return true if the type object includes support for the cycle detector; this
63   tests the type flag :const:`Py_TPFLAGS_HAVE_GC`.
64
65   .. versionadded:: 2.0
66
67
68.. cfunction:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
69
70   Return true if *a* is a subtype of *b*.
71
72   .. versionadded:: 2.2
73
74
75.. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
76
77   .. versionadded:: 2.2
78
79   .. versionchanged:: 2.5
80      This function used an :ctype:`int` type for *nitems*. This might require
81      changes in your code for properly supporting 64-bit systems.
82
83
84.. cfunction:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
85
86   .. versionadded:: 2.2
87
88
89.. cfunction:: int PyType_Ready(PyTypeObject *type)
90
91   Finalize a type object.  This should be called on all type objects to finish
92   their initialization.  This function is responsible for adding inherited slots
93   from a type's base class.  Return ``0`` on success, or return ``-1`` and sets an
94   exception on error.
95
96   .. versionadded:: 2.2