Mercurial > cpython-lru_cache-weakref
annotate Tools/scripts/google.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 | fcfe324663a6 |
| children |
| rev | line source |
|---|---|
|
59522
fcfe324663a6
convert shebang lines: python -> python3
Benjamin Peterson <benjamin@python.org>
parents:
42427
diff
changeset
|
1 #! /usr/bin/env python3 |
|
21185
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 import sys, webbrowser |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 def main(): |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 args = sys.argv[1:] |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 if not args: |
|
42427
46625e6122e9
Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents:
33074
diff
changeset
|
8 print("Usage: %s querystring" % sys.argv[0]) |
|
21185
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 return |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 list = [] |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 for arg in args: |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 if '+' in arg: |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 arg = arg.replace('+', '%2B') |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 if ' ' in arg: |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 arg = '"%s"' % arg |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 arg = arg.replace(' ', '+') |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 list.append(arg) |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 s = '+'.join(list) |
|
21888
836c1dbf23a0
www.google.com is better than google.com.
Guido van Rossum <guido@python.org>
parents:
21185
diff
changeset
|
19 url = "http://www.google.com/search?q=%s" % s |
|
21185
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 webbrowser.open(url) |
|
aebce485b56b
A tiny but useful script that fires off a search on Google.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 |
|
33074
981fff7363b9
[Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents:
21888
diff
changeset
|
22 if __name__ == '__main__': |
|
981fff7363b9
[Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents:
21888
diff
changeset
|
23 main() |
