annotate Include/classobject.h @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 62b61abd02b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44026
48af6375207e Removed the API to create unbound methods and simplified the API for bound methods. The signature is PyMethod_New(func, instance).
Christian Heimes <christian@cheimes.de>
parents: 39536
diff changeset
1 /* Former class object interface -- now only bound methods are here */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
1290
7971fecbf28e * Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents: 1289
diff changeset
3 /* Revealing some structures (not for general use) */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 45371
diff changeset
5 #ifndef Py_LIMITED_API
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
6 #ifndef Py_CLASSOBJECT_H
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
7 #define Py_CLASSOBJECT_H
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
8 #ifdef __cplusplus
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
9 extern "C" {
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
10 #endif
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
11
1289
4d292c7857d4 Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
12 typedef struct {
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
13 PyObject_HEAD
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
14 PyObject *im_func; /* The callable object implementing the method */
44026
48af6375207e Removed the API to create unbound methods and simplified the API for bound methods. The signature is PyMethod_New(func, instance).
Christian Heimes <christian@cheimes.de>
parents: 39536
diff changeset
15 PyObject *im_self; /* The instance it is bound to */
17169
d807488dfc7a Add the necessary field for weak reference support to the function and
Fred Drake <fdrake@acm.org>
parents: 16385
diff changeset
16 PyObject *im_weakreflist; /* List of weak references */
8657
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
17 } PyMethodObject;
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
18
39536
8f5b9982beba Completely get rid of PyClass and PyInstance.
Guido van Rossum <guido@python.org>
parents: 28527
diff changeset
19 PyAPI_DATA(PyTypeObject) PyMethod_Type;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
20
2129
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2074
diff changeset
21 #define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
44026
48af6375207e Removed the API to create unbound methods and simplified the API for bound methods. The signature is PyMethod_New(func, instance).
Christian Heimes <christian@cheimes.de>
parents: 39536
diff changeset
23 PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21300
diff changeset
25 PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21300
diff changeset
26 PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
19751
3d76dfc34c57 Add PyMethod_Function(), PyMethod_Self(), PyMethod_Class() back.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
27
8657
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
28 /* Macros for direct access to these values. Type checks are *not*
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
29 done, so use with care. */
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
30 #define PyMethod_GET_FUNCTION(meth) \
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
31 (((PyMethodObject *)meth) -> im_func)
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
32 #define PyMethod_GET_SELF(meth) \
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
33 (((PyMethodObject *)meth) -> im_self)
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
34
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: 44272
diff changeset
35 PyAPI_FUNC(int) PyMethod_ClearFreeList(void);
44272
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
36
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
37 typedef struct {
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
38 PyObject_HEAD
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
39 PyObject *func;
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
40 } PyInstanceMethodObject;
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
41
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
42 PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
43
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
44 #define PyInstanceMethod_Check(op) ((op)->ob_type == &PyInstanceMethod_Type)
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
45
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
46 PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
47 PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
48
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
49 /* Macros for direct access to these values. Type checks are *not*
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
50 done, so use with care. */
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
51 #define PyInstanceMethod_GET_FUNCTION(meth) \
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
52 (((PyInstanceMethodObject *)meth) -> func)
3e0867a07765 Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API
Christian Heimes <christian@cheimes.de>
parents: 44079
diff changeset
53
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
54 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
55 }
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
56 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
57 #endif /* !Py_CLASSOBJECT_H */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 45371
diff changeset
58 #endif /* Py_LIMITED_API */