Made a small optimization to __deepcopy__ in [6276].

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6279 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-09-15 11:13:21 +00:00
parent b361947745
commit 09060e9bc8
1 changed files with 5 additions and 5 deletions

View File

@ -1,5 +1,3 @@
import copy
def curry(_curried_func, *args, **kwargs): def curry(_curried_func, *args, **kwargs):
def _curried(*moreargs, **morekwargs): def _curried(*moreargs, **morekwargs):
return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs)) return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
@ -104,9 +102,11 @@ def lazy(func, *resultclasses):
raise AssertionError('__mod__ not supported for non-string types') raise AssertionError('__mod__ not supported for non-string types')
def __deepcopy__(self, memo): def __deepcopy__(self, memo):
result = copy.copy(self) # Instances of this class are effectively immutable. It's just a
memo[id(self)] = result # collection of functions. So we don't need to do anything
return result # complicated for copying.
memo[id(self)] = self
return self
def __wrapper__(*args, **kw): def __wrapper__(*args, **kw):
# Creates the proxy object, instead of the actual value. # Creates the proxy object, instead of the actual value.