Mercurial > cpython-lru_cache-weakref
annotate Include/genobject.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 | 862ab99ab570 |
| children |
| rev | line source |
|---|---|
|
32175
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
1 |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
2 /* Generator object interface */ |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
3 |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
44999
diff
changeset
|
4 #ifndef Py_LIMITED_API |
|
32175
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
5 #ifndef Py_GENOBJECT_H |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
6 #define Py_GENOBJECT_H |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
7 #ifdef __cplusplus |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
8 extern "C" { |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
9 #endif |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
10 |
|
32421
485d2ef43419
Patch #966493: Cleanup generator/eval_frame exposure.
Martin v. Löwis <martin@v.loewis.de>
parents:
32175
diff
changeset
|
11 struct _frame; /* Avoid including frameobject.h */ |
|
485d2ef43419
Patch #966493: Cleanup generator/eval_frame exposure.
Martin v. Löwis <martin@v.loewis.de>
parents:
32175
diff
changeset
|
12 |
|
32175
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
13 typedef struct { |
| 74378 | 14 PyObject_HEAD |
| 15 /* The gi_ prefix is intended to remind of generator-iterator. */ | |
|
32175
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
16 |
| 74378 | 17 /* Note: gi_frame can be NULL if the generator is "finished" */ |
| 18 struct _frame *gi_frame; | |
|
32175
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
19 |
| 74378 | 20 /* True if generator is being executed. */ |
|
75522
713db33a4ebc
Fix regression after c8d1df9ac987
Antoine Pitrou <solipsis@pitrou.net>
parents:
74378
diff
changeset
|
21 char gi_running; |
|
75714
72556ff86828
perform yield from delegation by repeating YIELD_FROM opcode (closes #14230)
Benjamin Peterson <benjamin@python.org>
parents:
75522
diff
changeset
|
22 |
| 74378 | 23 /* The code object backing the generator */ |
| 24 PyObject *gi_code; | |
|
32175
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
25 |
| 74378 | 26 /* List of weak reference. */ |
| 27 PyObject *gi_weakreflist; | |
|
32175
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
28 } PyGenObject; |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
29 |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
30 PyAPI_DATA(PyTypeObject) PyGen_Type; |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
31 |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
32 #define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) |
|
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
|
33 #define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type) |
|
32175
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
34 |
|
32421
485d2ef43419
Patch #966493: Cleanup generator/eval_frame exposure.
Martin v. Löwis <martin@v.loewis.de>
parents:
32175
diff
changeset
|
35 PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
32421
diff
changeset
|
36 PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *); |
|
77476
cfbf6aa5c9e3
Issue #13783: the PEP 380 implementation no longer expands the public C API
Nick Coghlan <ncoghlan@gmail.com>
parents:
75714
diff
changeset
|
37 PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **); |
|
75714
72556ff86828
perform yield from delegation by repeating YIELD_FROM opcode (closes #14230)
Benjamin Peterson <benjamin@python.org>
parents:
75522
diff
changeset
|
38 PyObject *_PyGen_Send(PyGenObject *, PyObject *); |
|
85046
862ab99ab570
Issue #17934: Add a clear() method to frame objects, to help clean up expensive details (local variables) and break reference cycles.
Antoine Pitrou <solipsis@pitrou.net>
parents:
83771
diff
changeset
|
39 PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self); |
|
862ab99ab570
Issue #17934: Add a clear() method to frame objects, to help clean up expensive details (local variables) and break reference cycles.
Antoine Pitrou <solipsis@pitrou.net>
parents:
83771
diff
changeset
|
40 |
|
32175
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
41 |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
42 #ifdef __cplusplus |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
43 } |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
44 #endif |
|
8ee5a56b8031
Patch #957398: Add public API for Generator Object/Type.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
45 #endif /* !Py_GENOBJECT_H */ |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
44999
diff
changeset
|
46 #endif /* Py_LIMITED_API */ |
