annotate Tools/scripts/lll.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
59522
fcfe324663a6 convert shebang lines: python -> python3
Benjamin Peterson <benjamin@python.org>
parents: 42427
diff changeset
1 #! /usr/bin/env python3
687
e15bea971a5b Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
e15bea971a5b Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # Find symbolic links and show where they point to.
e15bea971a5b Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 # Arguments are directories to search; default is current directory.
e15bea971a5b Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 # No recursion.
e15bea971a5b Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 # (This is a totally different program from "findsymlinks.py"!)
e15bea971a5b Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
755
2dd5dbf28a2d change posix to os
Guido van Rossum <guido@python.org>
parents: 687
diff changeset
8 import sys, os
687
e15bea971a5b Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
e15bea971a5b Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 def lll(dirname):
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
11 for name in os.listdir(dirname):
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
12 if name not in (os.curdir, os.pardir):
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
13 full = os.path.join(dirname, name)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
14 if os.path.islink(full):
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 33076
diff changeset
15 print(name, '->', os.readlink(full))
33074
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
16 def main():
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
17 args = sys.argv[1:]
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
18 if not args: args = [os.curdir]
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
19 first = 1
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
20 for arg in args:
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
21 if len(args) > 1:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 33076
diff changeset
22 if not first: print()
33074
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
23 first = 0
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 33076
diff changeset
24 print(arg + ':')
33074
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
25 lll(arg)
687
e15bea971a5b Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
26
33074
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
27 if __name__ == '__main__':
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
28 main()