##// END OF EJS Templates
util: use __code__ (available since py2.6)
timeless -
r28832:f5ff10f6 default
parent child Browse files
Show More
@@ -450,7 +450,7 b' extendeddateformats = defaultdateformats'
450 def cachefunc(func):
450 def cachefunc(func):
451 '''cache the result of function calls'''
451 '''cache the result of function calls'''
452 # XXX doesn't handle keywords args
452 # XXX doesn't handle keywords args
453 if func.func_code.co_argcount == 0:
453 if func.__code__.co_argcount == 0:
454 cache = []
454 cache = []
455 def f():
455 def f():
456 if len(cache) == 0:
456 if len(cache) == 0:
@@ -458,7 +458,7 b' def cachefunc(func):'
458 return cache[0]
458 return cache[0]
459 return f
459 return f
460 cache = {}
460 cache = {}
461 if func.func_code.co_argcount == 1:
461 if func.__code__.co_argcount == 1:
462 # we gain a small amount of time because
462 # we gain a small amount of time because
463 # we don't need to pack/unpack the list
463 # we don't need to pack/unpack the list
464 def f(arg):
464 def f(arg):
@@ -700,7 +700,7 b' def lrucachefunc(func):'
700 '''cache most recent results of function calls'''
700 '''cache most recent results of function calls'''
701 cache = {}
701 cache = {}
702 order = collections.deque()
702 order = collections.deque()
703 if func.func_code.co_argcount == 1:
703 if func.__code__.co_argcount == 1:
704 def f(arg):
704 def f(arg):
705 if arg not in cache:
705 if arg not in cache:
706 if len(cache) > 20:
706 if len(cache) > 20:
General Comments 0
You need to be logged in to leave comments. Login now