bpo-38565: add new cache_parameters method for lru_cache (GH-16916)

This commit is contained in:
Manjusaka 2019-11-12 15:30:18 +08:00 committed by Raymond Hettinger
parent 98480cef9d
commit 051ff526b5
4 changed files with 22 additions and 0 deletions

View file

@ -499,6 +499,7 @@ 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)
wrapper.cache_parameters = lambda : {'maxsize': maxsize, 'typed': typed}
return update_wrapper(wrapper, user_function)
elif maxsize is not None:
raise TypeError(
@ -506,6 +507,7 @@ def lru_cache(maxsize=128, typed=False):
def decorating_function(user_function):
wrapper = _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo)
wrapper.cache_parameters = lambda : {'maxsize': maxsize, 'typed': typed}
return update_wrapper(wrapper, user_function)
return decorating_function