Mercurial > cpython-lru_cache-weakref
annotate Doc/c-api/type.rst @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 74ff71b2f53d |
| children |
| rev | line source |
|---|---|
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
1 .. highlightlang:: c |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
3 .. _typeobjects: |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
4 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
5 Type Objects |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
6 ------------ |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
7 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
8 .. index:: object: type |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
9 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
10 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
11 .. c:type:: PyTypeObject |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
12 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
13 The C structure of the objects used to describe built-in types. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
14 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
15 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
16 .. c:var:: PyObject* PyType_Type |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
17 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
18 .. index:: single: TypeType (in module types) |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
19 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
20 This is the type object for type objects; it is the same object as ``type`` and |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
21 ``types.TypeType`` in the Python layer. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
22 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
23 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
24 .. c:function:: int PyType_Check(PyObject *o) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
25 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
26 Return true if the object *o* is a type object, including instances of types |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
27 derived from the standard type object. Return false in all other cases. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
28 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
29 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
30 .. c:function:: int PyType_CheckExact(PyObject *o) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
31 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
32 Return true if the object *o* is a type object, but not a subtype of the |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
33 standard type object. Return false in all other cases. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
34 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
35 .. versionadded:: 2.2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
36 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
37 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
38 .. c:function:: unsigned int PyType_ClearCache() |
|
45025
ea3fe302d392
Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
Christian Heimes <christian@cheimes.de>
parents:
44796
diff
changeset
|
39 |
|
47358
93fe913fae55
#2989: add PyType_Modified().
Georg Brandl <georg@python.org>
parents:
45025
diff
changeset
|
40 Clear the internal lookup cache. Return the current version tag. |
|
93fe913fae55
#2989: add PyType_Modified().
Georg Brandl <georg@python.org>
parents:
45025
diff
changeset
|
41 |
|
93fe913fae55
#2989: add PyType_Modified().
Georg Brandl <georg@python.org>
parents:
45025
diff
changeset
|
42 .. versionadded:: 2.6 |
|
93fe913fae55
#2989: add PyType_Modified().
Georg Brandl <georg@python.org>
parents:
45025
diff
changeset
|
43 |
|
93fe913fae55
#2989: add PyType_Modified().
Georg Brandl <georg@python.org>
parents:
45025
diff
changeset
|
44 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
45 .. c:function:: void PyType_Modified(PyTypeObject *type) |
|
47358
93fe913fae55
#2989: add PyType_Modified().
Georg Brandl <georg@python.org>
parents:
45025
diff
changeset
|
46 |
|
93fe913fae55
#2989: add PyType_Modified().
Georg Brandl <georg@python.org>
parents:
45025
diff
changeset
|
47 Invalidate the internal lookup cache for the type and all of its |
|
93fe913fae55
#2989: add PyType_Modified().
Georg Brandl <georg@python.org>
parents:
45025
diff
changeset
|
48 subtypes. This function must be called after any manual |
|
93fe913fae55
#2989: add PyType_Modified().
Georg Brandl <georg@python.org>
parents:
45025
diff
changeset
|
49 modification of the attributes or base classes of the type. |
|
45025
ea3fe302d392
Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
Christian Heimes <christian@cheimes.de>
parents:
44796
diff
changeset
|
50 |
|
ea3fe302d392
Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
Christian Heimes <christian@cheimes.de>
parents:
44796
diff
changeset
|
51 .. versionadded:: 2.6 |
|
ea3fe302d392
Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
Christian Heimes <christian@cheimes.de>
parents:
44796
diff
changeset
|
52 |
|
ea3fe302d392
Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
Christian Heimes <christian@cheimes.de>
parents:
44796
diff
changeset
|
53 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
54 .. c:function:: int PyType_HasFeature(PyObject *o, int feature) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
55 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
56 Return true if the type object *o* sets the feature *feature*. Type features |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
57 are denoted by single bit flags. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
58 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
59 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
60 .. c:function:: int PyType_IS_GC(PyObject *o) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
61 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
62 Return true if the type object includes support for the cycle detector; this |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
63 tests the type flag :const:`Py_TPFLAGS_HAVE_GC`. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
64 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
65 .. versionadded:: 2.0 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
66 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
67 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
68 .. c:function:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
69 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
70 Return true if *a* is a subtype of *b*. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
71 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
72 .. versionadded:: 2.2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
73 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
74 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
75 .. c:function:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
76 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
77 .. versionadded:: 2.2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
78 |
|
53588
817d8b28cd6b
Merged revisions 71873-71874,71882,71890,71893,71898-71900,71910,71914-71923,71925-71929,71931-71934,71937 via svnmerge from
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
47358
diff
changeset
|
79 .. versionchanged:: 2.5 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
80 This function used an :c:type:`int` type for *nitems*. This might require |
|
53588
817d8b28cd6b
Merged revisions 71873-71874,71882,71890,71893,71898-71900,71910,71914-71923,71925-71929,71931-71934,71937 via svnmerge from
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
47358
diff
changeset
|
81 changes in your code for properly supporting 64-bit systems. |
|
817d8b28cd6b
Merged revisions 71873-71874,71882,71890,71893,71898-71900,71910,71914-71923,71925-71929,71931-71934,71937 via svnmerge from
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
47358
diff
changeset
|
82 |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
83 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
84 .. c:function:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
85 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
86 .. versionadded:: 2.2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
87 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
88 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
56816
diff
changeset
|
89 .. c:function:: int PyType_Ready(PyTypeObject *type) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
90 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
91 Finalize a type object. This should be called on all type objects to finish |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
92 their initialization. This function is responsible for adding inherited slots |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
93 from a type's base class. Return ``0`` on success, or return ``-1`` and sets an |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
94 exception on error. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
95 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
96 .. versionadded:: 2.2 |
