BigBrotherBot v1.9.0
System Development Information for the BigBrotherBot project.

b3::decorators::memoize Class Reference

List of all members.

Public Member Functions

def __init__
def __get__
def __call__
def __init__
def __get__
def __call__

Public Attributes

 func

Detailed Description

cache the return value of a method

This class is meant to be used as a decorator of methods. The return value
from a given method invocation will be cached on the instance whose method
was invoked. All arguments passed to a method decorated with memoize must
be hashable.

If a memoized method is invoked directly on its class the result will not
be cached. Instead the method will be invoked like a static method:
class Obj(object):
    @memoize
    def add_to(self, arg):
        return self + arg
Obj.add_to(1) # not enough arguments
Obj.add_to(1, 2) # returns 3, result is not cached

See http://code.activestate.com/recipes/577452-a-memoize-decorator-for-instance-methods/

Constructor & Destructor Documentation

def b3::decorators::memoize::__init__ (   self,
  func 
)
def b3::decorators::memoize::__init__ (   self,
  func 
)

Member Function Documentation

def b3::decorators::memoize::__call__ (   self,
  args,
  kw 
)
def b3::decorators::memoize::__call__ (   self,
  args,
  kw 
)
def b3::decorators::memoize::__get__ (   self,
  obj,
  objtype = None 
)
def b3::decorators::memoize::__get__ (   self,
  obj,
  objtype = None 
)

Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Properties