              # method for the given type and method name.
              def __wrapper__(self, *args, **kw):
                  # Automatically triggers the evaluation of a lazy value and
                  # applies the given magic method of the result type.
                  res = self.__func(*self.__args, **self.__kw)
                  for t in type(res).mro():
                      if t in self.__dispatch:
                          return self.__dispatch[t][funcname](res, *args, **kw)
                  raise TypeError("Lazy object returned unexpected type.")
  
 
</s> remove         def __promise__(cls, klass, funcname, func):
 </s> add         def __promise__(cls, klass, funcname, method): </s> remove             cls.__dispatch[klass][funcname] = func
 </s> add             cls.__dispatch[klass][funcname] = method </s> remove                 (self.__func, self.__args, self.__kw) + resultclasses
 </s> add                 (func, self.__args, self.__kw) + resultclasses </s> remove             return str(self.__func(*self.__args, **self.__kw))
 </s> add             return str(func(*self.__args, **self.__kw)) </s> remove             return self.__func(*self.__args, **self.__kw)
 </s> add             return func(*self.__args, **self.__kw)
                res = func(*self.__args, **self.__kw)
              # method for the given type and method name.
              def __wrapper__(self, *args, **kw):
                  # Automatically triggers the evaluation of a lazy value and
                  # applies the given magic method of the result type.
                res = func(*self.__args, **self.__kw)
                  for t in type(res).mro():
                      if t in self.__dispatch:
                          return self.__dispatch[t][funcname](res, *args, **kw)
                  raise TypeError("Lazy object returned unexpected type.")
  
keep keep keep keep replace keep keep keep keep keep
 Try to save memory and time when using lazy objects by refering to their function via the closure, and not making it an attribute on each instance.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17360 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/utils/functional.py