~ubuntu-branches/ubuntu/trusty/python3.4/trusty-proposed

« back to all changes in this revision

Viewing changes to Doc/c-api/type.rst

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-11-25 09:44:27 UTC
  • Revision ID: package-import@ubuntu.com-20131125094427-lzxj8ap5w01lmo7f
Tags: upstream-3.4~b1
ImportĀ upstreamĀ versionĀ 3.4~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. highlightlang:: c
 
2
 
 
3
.. _typeobjects:
 
4
 
 
5
Type Objects
 
6
------------
 
7
 
 
8
.. index:: object: type
 
9
 
 
10
 
 
11
.. c:type:: PyTypeObject
 
12
 
 
13
   The C structure of the objects used to describe built-in types.
 
14
 
 
15
 
 
16
.. c:var:: PyObject* PyType_Type
 
17
 
 
18
   This is the type object for type objects; it is the same object as
 
19
   :class:`type` in the Python layer.
 
20
 
 
21
 
 
22
.. c:function:: int PyType_Check(PyObject *o)
 
23
 
 
24
   Return true if the object *o* is a type object, including instances of types
 
25
   derived from the standard type object.  Return false in all other cases.
 
26
 
 
27
 
 
28
.. c:function:: int PyType_CheckExact(PyObject *o)
 
29
 
 
30
   Return true if the object *o* is a type object, but not a subtype of the
 
31
   standard type object.  Return false in all other cases.
 
32
 
 
33
 
 
34
.. c:function:: unsigned int PyType_ClearCache()
 
35
 
 
36
   Clear the internal lookup cache. Return the current version tag.
 
37
 
 
38
.. c:function:: long PyType_GetFlags(PyTypeObject* type)
 
39
 
 
40
   Return the :c:member:`~PyTypeObject.tp_flags` member of *type*. This function is primarily
 
41
   meant for use with `Py_LIMITED_API`; the individual flag bits are
 
42
   guaranteed to be stable across Python releases, but access to
 
43
   :c:member:`~PyTypeObject.tp_flags` itself is not part of the limited API.
 
44
 
 
45
   .. versionadded:: 3.2
 
46
 
 
47
.. c:function:: void PyType_Modified(PyTypeObject *type)
 
48
 
 
49
   Invalidate the internal lookup cache for the type and all of its
 
50
   subtypes.  This function must be called after any manual
 
51
   modification of the attributes or base classes of the type.
 
52
 
 
53
 
 
54
.. c:function:: int PyType_HasFeature(PyTypeObject *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
.. c:function:: int PyType_IS_GC(PyTypeObject *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
 
 
66
.. c:function:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
 
67
 
 
68
   Return true if *a* is a subtype of *b*.
 
69
 
 
70
 
 
71
.. c:function:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
 
72
 
 
73
   Generic handler for the :c:member:`~PyTypeObject.tp_alloc` slot of a type object.  Use
 
74
   Python's default memory allocation mechanism to allocate a new instance and
 
75
   initialize all its contents to *NULL*.
 
76
 
 
77
.. c:function:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
 
78
 
 
79
   Generic handler for the :c:member:`~PyTypeObject.tp_new` slot of a type object.  Create a
 
80
   new instance using the type's :c:member:`~PyTypeObject.tp_alloc` slot.
 
81
 
 
82
.. c:function:: int PyType_Ready(PyTypeObject *type)
 
83
 
 
84
   Finalize a type object.  This should be called on all type objects to finish
 
85
   their initialization.  This function is responsible for adding inherited slots
 
86
   from a type's base class.  Return ``0`` on success, or return ``-1`` and sets an
 
87
   exception on error.
 
88
 
 
89
.. c:function:: PyObject* PyType_FromSpec(PyType_Spec *spec)
 
90
 
 
91
   Creates and returns a heap type object from the *spec* passed to the function.
 
92
 
 
93
.. c:function:: PyObject* PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
 
94
 
 
95
   Creates and returns a heap type object from the *spec*. In addition to that,
 
96
   the created heap type contains all types contained by the *bases* tuple as base
 
97
   types. This allows the caller to reference other heap types as base types.
 
98
 
 
99
   .. versionadded:: 3.3