Mercurial > cpython-lru_cache-weakref
annotate Doc/c-api/method.rst @ 79691:05c8928362ee
Merge __next__ method link fixes with 3.3.
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Fri, 12 Oct 2012 13:46:37 +0300 |
| parents | e19ccbbe70dd |
| children |
| rev | line source |
|---|---|
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
1 .. highlightlang:: c |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
2 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
3 .. _instancemethod-objects: |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
4 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
5 Instance Method Objects |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
6 ----------------------- |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
7 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
8 .. index:: object: instancemethod |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
9 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
10 An instance method is a wrapper for a :c:data:`PyCFunction` and the new way |
|
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
11 to bind a :c:data:`PyCFunction` to a class object. It replaces the former call |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
12 ``PyMethod_New(func, NULL, class)``. |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
13 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
14 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
15 .. c:var:: PyTypeObject PyInstanceMethod_Type |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
16 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
17 This instance of :c:type:`PyTypeObject` represents the Python instance |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
18 method type. It is not exposed to Python programs. |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
19 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
20 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
21 .. c:function:: int PyInstanceMethod_Check(PyObject *o) |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
22 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
23 Return true if *o* is an instance method object (has type |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
24 :c:data:`PyInstanceMethod_Type`). The parameter must not be *NULL*. |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
25 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
26 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
27 .. c:function:: PyObject* PyInstanceMethod_New(PyObject *func) |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
28 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
29 Return a new instance method object, with *func* being any callable object |
|
72985
e19ccbbe70dd
Remove duplication.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
65137
diff
changeset
|
30 *func* is the function that will be called when the instance method is |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
31 called. |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
32 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
33 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
34 .. c:function:: PyObject* PyInstanceMethod_Function(PyObject *im) |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
35 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
36 Return the function object associated with the instance method *im*. |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
37 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
38 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
39 .. c:function:: PyObject* PyInstanceMethod_GET_FUNCTION(PyObject *im) |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
40 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
41 Macro version of :c:func:`PyInstanceMethod_Function` which avoids error checking. |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
42 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
43 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
44 .. _method-objects: |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
45 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
46 Method Objects |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
47 -------------- |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
48 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
49 .. index:: object: method |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
50 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
51 Methods are bound function objects. Methods are always bound to an instance of |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
52 an user-defined class. Unbound methods (methods bound to a class object) are |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
53 no longer available. |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
54 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
55 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
56 .. c:var:: PyTypeObject PyMethod_Type |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
57 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
58 .. index:: single: MethodType (in module types) |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
59 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
60 This instance of :c:type:`PyTypeObject` represents the Python method type. This |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
61 is exposed to Python programs as ``types.MethodType``. |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
62 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
63 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
64 .. c:function:: int PyMethod_Check(PyObject *o) |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
65 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
66 Return true if *o* is a method object (has type :c:data:`PyMethod_Type`). The |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
67 parameter must not be *NULL*. |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
68 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
69 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
70 .. c:function:: PyObject* PyMethod_New(PyObject *func, PyObject *self) |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
71 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
72 Return a new method object, with *func* being any callable object and *self* |
|
72985
e19ccbbe70dd
Remove duplication.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
65137
diff
changeset
|
73 the instance the method should be bound. *func* is the function that will |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
74 be called when the method is called. *self* must not be *NULL*. |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
75 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
76 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
77 .. c:function:: PyObject* PyMethod_Function(PyObject *meth) |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
78 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
79 Return the function object associated with the method *meth*. |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
80 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
81 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
82 .. c:function:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth) |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
83 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
84 Macro version of :c:func:`PyMethod_Function` which avoids error checking. |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
85 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
86 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
87 .. c:function:: PyObject* PyMethod_Self(PyObject *meth) |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
88 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
89 Return the instance associated with the method *meth*. |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
90 |
|
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
91 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
92 .. c:function:: PyObject* PyMethod_GET_SELF(PyObject *meth) |
|
44812
1e8b9e7c34ce
Split C API docs in Py3k branch.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
93 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
94 Macro version of :c:func:`PyMethod_Self` which avoids error checking. |
|
45371
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44812
diff
changeset
|
95 |
|
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44812
diff
changeset
|
96 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
55580
diff
changeset
|
97 .. c:function:: int PyMethod_ClearFreeList() |
|
45371
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44812
diff
changeset
|
98 |
|
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44812
diff
changeset
|
99 Clear the free list. Return the total number of freed items. |
|
7c4c46342137
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44812
diff
changeset
|
100 |
