Refs #32355 -- Used @functools.lru_cache as a straight decorator.
This commit is contained in:
parent
840ad06300
commit
5bac1719a2
|
@ -83,7 +83,7 @@ def make_password(password, salt=None, hasher='default'):
|
|||
return hasher.encode(password, salt)
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def get_hashers():
|
||||
hashers = []
|
||||
for hasher_path in settings.PASSWORD_HASHERS:
|
||||
|
@ -96,7 +96,7 @@ def get_hashers():
|
|||
return hashers
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def get_hashers_by_algorithm():
|
||||
return {hasher.algorithm: hasher for hasher in get_hashers()}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from django.db import connections
|
|||
from django.db.backends.base.base import NO_DB_ALIAS
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def get_hstore_oids(connection_alias):
|
||||
"""Return hstore and hstore array OIDs."""
|
||||
with connections[connection_alias].cursor() as cursor:
|
||||
|
@ -26,7 +26,7 @@ def get_hstore_oids(connection_alias):
|
|||
return tuple(oids), tuple(array_oids)
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def get_citext_oids(connection_alias):
|
||||
"""Return citext array OIDs."""
|
||||
with connections[connection_alias].cursor() as cursor:
|
||||
|
|
|
@ -38,9 +38,9 @@ def unpickle_named_row(names, values):
|
|||
return create_namedtuple_class(*names)(*values)
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def create_namedtuple_class(*names):
|
||||
# Cache type() with @lru_cache() since it's too slow to be called for every
|
||||
# Cache type() with @lru_cache since it's too slow to be called for every
|
||||
# QuerySet evaluation.
|
||||
def __reduce__(self):
|
||||
return unpickle_named_row, (names, tuple(self))
|
||||
|
|
|
@ -8,7 +8,7 @@ from django.utils.functional import cached_property
|
|||
from django.utils.module_loading import import_string
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def get_default_renderer():
|
||||
renderer_class = import_string(settings.FORM_RENDERER)
|
||||
return renderer_class()
|
||||
|
|
|
@ -73,7 +73,7 @@ class Engine:
|
|||
)
|
||||
|
||||
@staticmethod
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def get_default():
|
||||
"""
|
||||
Return the first DjangoTemplates backend that's configured, or raise
|
||||
|
|
|
@ -90,7 +90,7 @@ class EngineHandler:
|
|||
return [self[alias] for alias in self]
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def get_app_template_dirs(dirname):
|
||||
"""
|
||||
Return an iterable of paths of directories to load app templates from.
|
||||
|
|
|
@ -441,7 +441,7 @@ class WatchmanReloader(BaseReloader):
|
|||
logger.debug('Watchman watch-project result: %s', result)
|
||||
return result['watch'], result.get('relative_path')
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def _get_clock(self, root):
|
||||
return self.client.query('clock', root)['clock']
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ def localize_input(value, default=None):
|
|||
return value
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def sanitize_strftime_format(fmt):
|
||||
"""
|
||||
Ensure that certain specifiers are correctly padded with leading zeros.
|
||||
|
|
|
@ -47,7 +47,7 @@ def get_fixed_timezone(offset):
|
|||
|
||||
# In order to avoid accessing settings at compile time,
|
||||
# wrap the logic in a function and cache the result.
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def get_default_timezone():
|
||||
"""
|
||||
Return the default time zone as a tzinfo instance.
|
||||
|
|
|
@ -452,7 +452,7 @@ def check_for_language(lang_code):
|
|||
)
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def get_languages():
|
||||
"""
|
||||
Cache of settings.LANGUAGES in a dictionary for easy lookups by key.
|
||||
|
|
|
@ -70,7 +70,7 @@ def get_docs_version(version=None):
|
|||
return '%d.%d' % version[:2]
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def get_git_changeset():
|
||||
"""Return a numeric identifier of the latest git changeset.
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ def technical_500_response(request, exc_type, exc_value, tb, status_code=500):
|
|||
return HttpResponse(text, status=status_code, content_type='text/plain; charset=utf-8')
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache
|
||||
def get_default_exception_reporter_filter():
|
||||
# Instantiate the default filter for the first time and cache it.
|
||||
return import_string(settings.DEFAULT_EXCEPTION_REPORTER_FILTER)()
|
||||
|
|
Loading…
Reference in New Issue