equal
deleted
inserted
replaced
24 class SignalInterrupt(Exception): |
24 class SignalInterrupt(Exception): |
25 """Exception raised on SIGTERM and SIGHUP.""" |
25 """Exception raised on SIGTERM and SIGHUP.""" |
26 |
26 |
27 def cachefunc(func): |
27 def cachefunc(func): |
28 '''cache the result of function calls''' |
28 '''cache the result of function calls''' |
|
29 # XXX doesn't handle keywords args |
29 cache = {} |
30 cache = {} |
30 if func.func_code.co_argcount == 1: |
31 if func.func_code.co_argcount == 1: |
|
32 # we gain a small amount of time because |
|
33 # we don't need to pack/unpack the list |
31 def f(arg): |
34 def f(arg): |
32 if arg not in cache: |
35 if arg not in cache: |
33 cache[arg] = func(arg) |
36 cache[arg] = func(arg) |
34 return cache[arg] |
37 return cache[arg] |
35 else: |
38 else: |