Mercurial > cpython-lru_cache-weakref
annotate PC/python34gen.py @ 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 | 1085b0e475d8 |
| children |
| rev | line source |
|---|---|
|
79240
1085b0e475d8
Bump version to 3.4.0 alpha 0.
Georg Brandl <georg@python.org>
parents:
77653
diff
changeset
|
1 # Generate python34stub.def out of python3.def |
| 68136 | 2 # The regular import library cannot be used, |
| 3 # since it doesn't provide the right symbols for | |
| 4 # data forwarding | |
|
79240
1085b0e475d8
Bump version to 3.4.0 alpha 0.
Georg Brandl <georg@python.org>
parents:
77653
diff
changeset
|
5 out = open("python34stub.def", "w") |
|
1085b0e475d8
Bump version to 3.4.0 alpha 0.
Georg Brandl <georg@python.org>
parents:
77653
diff
changeset
|
6 out.write('LIBRARY "python34"\n') |
| 68136 | 7 out.write('EXPORTS\n') |
| 8 | |
| 9 inp = open("python3.def") | |
| 10 line = inp.readline() | |
|
77653
3f14119e4af7
Issue #11626: Add _SizeT functions to stable ABI.
Martin v. Löwis <martin@v.loewis.de>
parents:
68258
diff
changeset
|
11 while line.strip().startswith(';'): |
|
3f14119e4af7
Issue #11626: Add _SizeT functions to stable ABI.
Martin v. Löwis <martin@v.loewis.de>
parents:
68258
diff
changeset
|
12 line = inp.readline() |
|
3f14119e4af7
Issue #11626: Add _SizeT functions to stable ABI.
Martin v. Löwis <martin@v.loewis.de>
parents:
68258
diff
changeset
|
13 line = inp.readline() # LIBRARY |
| 68136 | 14 assert line.strip()=='EXPORTS' |
| 15 | |
| 16 for line in inp: | |
|
79240
1085b0e475d8
Bump version to 3.4.0 alpha 0.
Georg Brandl <georg@python.org>
parents:
77653
diff
changeset
|
17 # SYM1=python34.SYM2[ DATA] |
| 68136 | 18 head, tail = line.split('.') |
| 19 if 'DATA' in tail: | |
| 20 symbol, tail = tail.split(' ') | |
| 21 else: | |
| 22 symbol = tail.strip() | |
| 23 out.write(symbol+'\n') | |
| 24 | |
| 25 inp.close() | |
| 26 out.close() |
