Serhiy Storchaka <[email protected]> added the comment:
It is easy:
diff --git a/Lib/functools.py b/Lib/functools.py
index 3192bd02d9..52c07db749 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -499,7 +499,9 @@ def lru_cache(maxsize=128, typed=False):
# The user_function was passed in directly via the maxsize argument
user_function, maxsize = maxsize, 128
wrapper = _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo)
- return update_wrapper(wrapper, user_function)
+ func = update_wrapper(wrapper, user_function)
+ func.cache_parameters = lambda: {'maxsize': maxsize, 'typed': typed}
+ return func
elif maxsize is not None:
raise TypeError(
'Expected first argument to be an integer, a callable, or None')
But there are many design questions. Why method instead of just attribute?
func.cache_parameters = {'maxsize': maxsize, 'typed': typed}
Or maybe just add the "typed" attribute?
func.typed = typed
Also I consider adding the more general "make_key" parameter to lru_cache().
The "typed" parameter would just specify the default value for "make_key".
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38565>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com