diff options
author | Bouke Haarsma <bouke@webatoom.nl> | 2013-11-01 21:15:41 +0100 |
---|---|---|
committer | Baptiste Mispelon <bmispelon@gmail.com> | 2013-11-11 08:53:09 +0100 |
commit | 9b7455e918a437c3db91e88dcbf6d9c93fef96f8 (patch) | |
tree | 4cda7466ec20e5255633e7447eaa03ad5450bf24 /tests/decorators | |
parent | 6c5f5b9a414b8bdfafc45db5710acf200cca9885 (diff) | |
download | django-9b7455e918a437c3db91e88dcbf6d9c93fef96f8.tar.gz |
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.
Diffstat (limited to 'tests/decorators')
-rw-r--r-- | tests/decorators/tests.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/decorators/tests.py b/tests/decorators/tests.py index db00f36051..9c654e500a 100644 --- a/tests/decorators/tests.py +++ b/tests/decorators/tests.py @@ -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) |