1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #21351 -- Replaced memoize with Python's lru_cache.

Replaced the custom, untested memoize with a similar decorator from Python's
3.2 stdlib. Although some minor performance degradation (see ticket), it is
expected that in the long run lru_cache will outperform memoize once it is
implemented in C.

Thanks to EvilDMP for the report and Baptiste Mispelon for the idea of
replacing memoize with lru_cache.
This commit is contained in:
Bouke Haarsma
2013-11-01 21:15:41 +01:00
committed by Baptiste Mispelon
parent 6c5f5b9a41
commit 9b7455e918
13 changed files with 254 additions and 38 deletions

View File

@@ -1,5 +1,6 @@
from functools import wraps
from unittest import TestCase
import warnings
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required, permission_required, user_passes_test
@@ -58,11 +59,14 @@ full_decorator = compose(
staff_member_required,
# django.utils.functional
lambda f: memoize(f, {}, 1),
allow_lazy,
lazy,
)
# suppress the deprecation warning of memoize
with warnings.catch_warnings(record=True):
fully_decorated = memoize(fully_decorated, {}, 1)
fully_decorated = full_decorator(fully_decorated)