parameters: (obj)
return_statement: return Cacher
docstring: Decorator for caching read-only properties.
  
    Example usage (always returns the same Foo instance):
      @Cache
      def CreateFoo():
        return Foo()
  
    If CreateFoo() accepts parameters, a separate cached value is maintained
    for each unique parameter combination.
  
    Cached methods maintain their cache for the lifetime of the /instance/, while
    cached functions maintain their cache for the lifetime of the /module/.
docstring_summary: Decorator for caching read-only properties.
docstring_tokens: Decorator for caching read - only properties .
function: def Cache(obj):
    """Decorator for caching read-only properties.
  
    Example usage (always returns the same Foo instance):
      @Cache
      def CreateFoo():
        return Foo()
  
    If CreateFoo() accepts parameters, a separate cached value is maintained
    for each unique parameter combination.
  
    Cached methods maintain their cache for the lifetime of the /instance/, while
    cached functions maintain their cache for the lifetime of the /module/.
    """
    @functools.wraps(obj)
    def Cacher(*args, **kwargs):
      cacher = args[0] if inspect.getargspec(obj).args[:1] == ['self'] else obj
      cacher.__cache = cacher.__cache if hasattr(cacher, '__cache') else {}
      key = str(obj) + str(args) + str(kwargs)
      if key not in cacher.__cache:
        cacher.__cache[key] = obj(*args, **kwargs)
      return cacher.__cache[key]
    return Cacher
function_tokens: def Cache ( obj ) : @ functools . wraps ( obj ) def Cacher ( * args , * * kwargs ) : cacher = args [ 0 ] if inspect . getargspec ( obj ) . args [ : 1 ] == [ 'self' ] else obj cacher . __cache = cacher . __cache if hasattr ( cacher , '__cache' ) else { } key = str ( obj ) + str ( args ) + str ( kwargs ) if key not in cacher . __cache : cacher . __cache [ key ] = obj ( * args , * * kwargs ) return cacher . __cache [ key ] return Cacher