summaryrefslogtreecommitdiffstats
path: root/Lib/functools.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2020-05-12 00:00:53 (GMT)
committerGitHub <noreply@github.com>2020-05-12 00:00:53 (GMT)
commit21cdb711e3b1975398c54141e519ead02670610e (patch)
treebbe4a1006ff4a8d3f6e280eb556b7c25cccb1f4c /Lib/functools.py
parent4804b5b3df82e7892ca0550b02f902bcfc16bb48 (diff)
downloadcpython-21cdb711e3b1975398c54141e519ead02670610e.zip
cpython-21cdb711e3b1975398c54141e519ead02670610e.tar.gz
cpython-21cdb711e3b1975398c54141e519ead02670610e.tar.bz2
bpo-40571: Make lru_cache(maxsize=None) more discoverable (GH-20019)
Diffstat (limited to 'Lib/functools.py')
-rw-r--r--Lib/functools.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index f05b106..87c7d87 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -10,7 +10,7 @@
# See C source code for _functools credits/copyright
__all__ = ['update_wrapper', 'wraps', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES',
- 'total_ordering', 'cmp_to_key', 'lru_cache', 'reduce',
+ 'total_ordering', 'cache', 'cmp_to_key', 'lru_cache', 'reduce',
'TopologicalSorter', 'CycleError',
'partial', 'partialmethod', 'singledispatch', 'singledispatchmethod',
'cached_property']
@@ -889,6 +889,15 @@ except ImportError:
################################################################################
+### cache -- simplified access to the infinity cache
+################################################################################
+
+def cache(user_function, /):
+ 'Simple lightweight unbounded cache. Sometimes called "memoize".'
+ return lru_cache(maxsize=None)(user_function)
+
+
+################################################################################
### singledispatch() - single-dispatch generic function decorator
################################################################################