This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Python 装饰器 | |
| #http://programmingbits.pythonblogs.com/27_programmingbits/archive/50_function_decorators.html | |
| def memoize(f): | |
| cache = {} | |
| def helper(x): | |
| if x not in cache: | |
| cache[x] = f(x) | |
| return cache[x] | |
| return helper |
NewerOlder