摘要: 1,Memoizing(自动缓存) 话不多说,看个例子。import time,hashlib,picklecache = {}def is_obsolete(entry,duration): return time.time() - entry['time'] > durationdef compute_key(function,args,kw): key = pickle.dumps((function.func_name,args,kw)) return hashlib.sha1(key).hexdigest()def memoize(duration=10): . 阅读全文
posted @ 2013-05-14 14:36 jiezhao 阅读(6568) 评论(0) 推荐(0) 编辑