From 5bac1719a2fcbee5cb8b9e22c3480e3a24ed6c4c Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Mon, 27 Sep 2021 09:10:58 +0200 Subject: [PATCH] Refs #32355 -- Used @functools.lru_cache as a straight decorator. --- django/contrib/auth/hashers.py | 4 ++-- django/contrib/postgres/signals.py | 4 ++-- django/db/models/utils.py | 4 ++-- django/forms/renderers.py | 2 +- django/template/engine.py | 2 +- django/template/utils.py | 2 +- django/utils/autoreload.py | 2 +- django/utils/formats.py | 2 +- django/utils/timezone.py | 2 +- django/utils/translation/trans_real.py | 2 +- django/utils/version.py | 2 +- django/views/debug.py | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py index 619f61ee3bd..be42cae3c06 100644 --- a/django/contrib/auth/hashers.py +++ b/django/contrib/auth/hashers.py @@ -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()} diff --git a/django/contrib/postgres/signals.py b/django/contrib/postgres/signals.py index abfd89005d2..420b5f6033f 100644 --- a/django/contrib/postgres/signals.py +++ b/django/contrib/postgres/signals.py @@ -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: diff --git a/django/db/models/utils.py b/django/db/models/utils.py index a8bd20fba7f..949c5284696 100644 --- a/django/db/models/utils.py +++ b/django/db/models/utils.py @@ -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)) diff --git a/django/forms/renderers.py b/django/forms/renderers.py index ce3b7097e68..ffb61600c2c 100644 --- a/django/forms/renderers.py +++ b/django/forms/renderers.py @@ -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() diff --git a/django/template/engine.py b/django/template/engine.py index 0adc20cfb3f..91e503f7090 100644 --- a/django/template/engine.py +++ b/django/template/engine.py @@ -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 diff --git a/django/template/utils.py b/django/template/utils.py index 2d30e1637a3..ad7baba2f35 100644 --- a/django/template/utils.py +++ b/django/template/utils.py @@ -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. diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py index 15df088c481..cc65c043ab3 100644 --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -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'] diff --git a/django/utils/formats.py b/django/utils/formats.py index 781d334a8e4..3aef3bc23c7 100644 --- a/django/utils/formats.py +++ b/django/utils/formats.py @@ -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. diff --git a/django/utils/timezone.py b/django/utils/timezone.py index 0c23486c1f0..9572c99bac5 100644 --- a/django/utils/timezone.py +++ b/django/utils/timezone.py @@ -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. diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 173ad086394..7dcc77b46cd 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -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. diff --git a/django/utils/version.py b/django/utils/version.py index 3ce6f465bd7..7f4e9e3cce8 100644 --- a/django/utils/version.py +++ b/django/utils/version.py @@ -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. diff --git a/django/views/debug.py b/django/views/debug.py index 16c9ad7fc87..da9a17e60f4 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -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)()