@public
def cache_value(duration=None):
 def decorator(fx):
  fx.__cached = None
  fx.__cached_at = 0
  def wrapper(*args, **kwargs):
   dt = (time.time() - fx.__cached_at)
   if (((dt > duration) and (duration is not None)) or ((fx.__cached_at == 0) and (duration is None))):
    val = fx(*args, **kwargs)
    fx.__cached = val
    fx.__cached_at = time.time()
   else:
    val = fx.__cached
   return val
  wrapper.__doc__ = fx.__doc__
  return wrapper
 return decorator

@ public def cache_value ( duration = None ) : def decorator ( fx ) : fx . __cached = None fx . __cached_at = 0 def wrapper ( * args , ** kwargs ) : dt = ( time . time ( ) - fx . __cached_at ) if ( ( ( dt > duration ) and ( duration is not None ) ) or ( ( fx . __cached_at == 0 ) and ( duration is None ) ) ) : val = fx ( * args , ** kwargs ) fx . __cached = val fx . __cached_at = time . time ( ) else : val = fx . __cached return val wrapper . __doc__ = fx . __doc__ return wrapper return decorator
makes a function lazy .