Mercurial > cpython-lru_cache-weakref
annotate Include/bitset.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 | 6f6f965c5e2d |
| children |
| rev | line source |
|---|---|
| 145 | 1 |
|
13443
7e58c060d534
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
2 #ifndef Py_BITSET_H |
|
7e58c060d534
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
3 #define Py_BITSET_H |
|
7e58c060d534
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
4 #ifdef __cplusplus |
|
7e58c060d534
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
5 extern "C" { |
|
7e58c060d534
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
6 #endif |
|
7e58c060d534
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
7 |
| 6 | 8 /* Bitset interface */ |
| 9 | |
| 10 #define BYTE char | |
| 11 | |
| 12 typedef BYTE *bitset; | |
| 13 | |
|
13443
7e58c060d534
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
14 bitset newbitset(int nbits); |
|
7e58c060d534
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
15 void delbitset(bitset bs); |
|
2043
4ebee904924e
Lots of small things, see ChangeLog
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
16 #define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0) |
|
13443
7e58c060d534
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
17 int addbit(bitset bs, int ibit); /* Returns 0 if already set */ |
|
7e58c060d534
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
18 int samebitset(bitset bs1, bitset bs2, int nbits); |
|
7e58c060d534
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
19 void mergebitset(bitset bs1, bitset bs2, int nbits); |
| 6 | 20 |
| 21 #define BITSPERBYTE (8*sizeof(BYTE)) | |
| 22 #define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE) | |
| 23 | |
| 24 #define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE) | |
| 25 #define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE) | |
| 26 #define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit)) | |
| 27 #define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE) | |
| 28 | |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
29 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
30 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
31 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
32 #endif /* !Py_BITSET_H */ |
