Mercurial > cpython-lru_cache-weakref
annotate PC/testpy.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 | 87a0fdcaa84a |
| children |
| rev | line source |
|---|---|
|
36763
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
1 import sys |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
2 |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
3 # This is a test module for Python. It looks in the standard |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
4 # places for various *.py files. If these are moved, you must |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
5 # change this module too. |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
6 |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
7 try: |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36763
diff
changeset
|
8 import os |
|
36763
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
9 except: |
|
43080
87a0fdcaa84a
Fix more lingering print statements.
Collin Winter <collinw@gmail.com>
parents:
37879
diff
changeset
|
10 print("""Could not import the standard "os" module. |
|
87a0fdcaa84a
Fix more lingering print statements.
Collin Winter <collinw@gmail.com>
parents:
37879
diff
changeset
|
11 Please check your PYTHONPATH environment variable.""") |
|
36763
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
12 sys.exit(1) |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
13 |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
14 try: |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36763
diff
changeset
|
15 import symbol |
|
36763
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
16 except: |
|
43080
87a0fdcaa84a
Fix more lingering print statements.
Collin Winter <collinw@gmail.com>
parents:
37879
diff
changeset
|
17 print("""Could not import the standard "symbol" module. If this is |
|
87a0fdcaa84a
Fix more lingering print statements.
Collin Winter <collinw@gmail.com>
parents:
37879
diff
changeset
|
18 a PC, you should add the dos_8x3 directory to your PYTHONPATH.""") |
|
36763
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
19 sys.exit(1) |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
20 |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
21 import os |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
22 |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
23 for dir in sys.path: |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36763
diff
changeset
|
24 file = os.path.join(dir, "os.py") |
|
36763
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
25 if os.path.isfile(file): |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
26 test = os.path.join(dir, "test") |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
27 if os.path.isdir(test): |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
28 # Add the "test" directory to PYTHONPATH. |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
29 sys.path = sys.path + [test] |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
30 |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
31 import regrtest # Standard Python tester. |
|
5e463ae70707
Remove svn:mime-type (inexplicably set to a binary type),
Tim Peters <tim.peters@gmail.com>
parents:
32737
diff
changeset
|
32 regrtest.main() |
