mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #4566 -- Added caching speed-ups to reverse URL matching. Based on a
patch from smoo.master@gmail.com. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5516 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -3,6 +3,21 @@ def curry(_curried_func, *args, **kwargs):
|
||||
return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
|
||||
return _curried
|
||||
|
||||
def memoize(func, cache):
|
||||
"""
|
||||
Wrap a function so that results for any argument tuple are stored in
|
||||
'cache'. Note that the args to the function must be usable as dictionary
|
||||
keys.
|
||||
"""
|
||||
def wrapper(*args):
|
||||
if args in cache:
|
||||
return cache[args]
|
||||
|
||||
result = func(*args)
|
||||
cache[args] = result
|
||||
return result
|
||||
return wrapper
|
||||
|
||||
class Promise:
|
||||
"""
|
||||
This is just a base class for the proxy class created in
|
||||
|
||||
Reference in New Issue
Block a user