Mercurial > cpython-lru_cache-weakref
annotate Include/cellobject.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 |
| rev | line source |
|---|---|
| 16256 | 1 /* Cell object interface */ |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
2 #ifndef Py_LIMITED_API |
| 16256 | 3 #ifndef Py_CELLOBJECT_H |
| 4 #define Py_CELLOBJECT_H | |
| 5 #ifdef __cplusplus | |
| 6 extern "C" { | |
| 7 #endif | |
| 8 | |
| 9 typedef struct { | |
|
22293
24af842030a0
backport jhylton's checkin of
Michael W. Hudson <mwh@python.net>
parents:
16256
diff
changeset
|
10 PyObject_HEAD |
|
33856
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
24752
diff
changeset
|
11 PyObject *ob_ref; /* Content of the cell or NULL when empty */ |
| 16256 | 12 } PyCellObject; |
| 13 | |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22293
diff
changeset
|
14 PyAPI_DATA(PyTypeObject) PyCell_Type; |
| 16256 | 15 |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
16 #define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type) |
| 16256 | 17 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22293
diff
changeset
|
18 PyAPI_FUNC(PyObject *) PyCell_New(PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22293
diff
changeset
|
19 PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22293
diff
changeset
|
20 PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *); |
| 16256 | 21 |
| 22 #define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref) | |
| 23 #define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v) | |
| 24 | |
| 25 #ifdef __cplusplus | |
| 26 } | |
| 27 #endif | |
| 28 #endif /* !Py_TUPLEOBJECT_H */ | |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
44351
diff
changeset
|
29 #endif /* Py_LIMITED_API */ |
