mirror of
https://github.com/django/django.git
synced 2025-09-16 23:45:38 +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:
parent
6c5f5b9a41
commit
9b7455e918
13 changed files with 254 additions and 38 deletions
|
@ -2,6 +2,7 @@ import copy
|
|||
import operator
|
||||
from functools import wraps
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.six.moves import copyreg
|
||||
|
@ -24,6 +25,10 @@ def memoize(func, cache, num_args):
|
|||
|
||||
Only the first num_args are considered when creating the key.
|
||||
"""
|
||||
warnings.warn(u"memoize wrapper is deprecated and will be removed in "
|
||||
u"Django 1.9. Use django.utils.lru_cache instead.",
|
||||
PendingDeprecationWarning, 2)
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args):
|
||||
mem_args = args[:num_args]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue