##// 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 450 def cachefunc(func):
451 451 '''cache the result of function calls'''
452 452 # XXX doesn't handle keywords args
453 if func.func_code.co_argcount == 0:
453 if func.__code__.co_argcount == 0:
454 454 cache = []
455 455 def f():
456 456 if len(cache) == 0:
@@ -458,7 +458,7 b' def cachefunc(func):'
458 458 return cache[0]
459 459 return f
460 460 cache = {}
461 if func.func_code.co_argcount == 1:
461 if func.__code__.co_argcount == 1:
462 462 # we gain a small amount of time because
463 463 # we don't need to pack/unpack the list
464 464 def f(arg):
@@ -700,7 +700,7 b' def lrucachefunc(func):'
700 700 '''cache most recent results of function calls'''
701 701 cache = {}
702 702 order = collections.deque()
703 if func.func_code.co_argcount == 1:
703 if func.__code__.co_argcount == 1:
704 704 def f(arg):
705 705 if arg not in cache:
706 706 if len(cache) > 20:
General Comments 0
You need to be logged in to leave comments. Login now