~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

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
.. 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
 
 
36
.. cfunction:: unsigned int PyType_ClearCache(void)
 
37
 
 
38
   Clear the internal lookup cache. Return the current version tag.
 
39
 
 
40
 
 
41
.. cfunction:: void PyType_Modified(PyTypeObject *type)
 
42
 
 
43
   Invalidate the internal lookup cache for the type and all of its
 
44
   subtypes.  This function must be called after any manual
 
45
   modification of the attributes or base classes of the type.
 
46
 
 
47
 
 
48
.. cfunction:: int PyType_HasFeature(PyObject *o, int feature)
 
49
 
 
50
   Return true if the type object *o* sets the feature *feature*.  Type features
 
51
   are denoted by single bit flags.
 
52
 
 
53
 
 
54
.. cfunction:: int PyType_IS_GC(PyObject *o)
 
55
 
 
56
   Return true if the type object includes support for the cycle detector; this
 
57
   tests the type flag :const:`Py_TPFLAGS_HAVE_GC`.
 
58
 
 
59
 
 
60
.. cfunction:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
 
61
 
 
62
   Return true if *a* is a subtype of *b*.
 
63
 
 
64
 
 
65
.. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
 
66
 
 
67
   XXX: Document.
 
68
 
 
69
 
 
70
.. cfunction:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
 
71
 
 
72
   XXX: Document.
 
73
 
 
74
 
 
75
.. cfunction:: int PyType_Ready(PyTypeObject *type)
 
76
 
 
77
   Finalize a type object.  This should be called on all type objects to finish
 
78
   their initialization.  This function is responsible for adding inherited slots
 
79
   from a type's base class.  Return ``0`` on success, or return ``-1`` and sets an
 
80
   exception on error.