Message355288
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". |
|
Date |
User |
Action |
Args |
2019-10-24 07:33:27 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, Scott Sanderson2, Manjusaka |
2019-10-24 07:33:27 | serhiy.storchaka | set | messageid: <1571902407.8.0.871942398982.issue38565@roundup.psfhosted.org> |
2019-10-24 07:33:27 | serhiy.storchaka | link | issue38565 messages |
2019-10-24 07:33:27 | serhiy.storchaka | create | |
|