mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bpo-38565: add new cache_parameters method for lru_cache (GH-16916)
This commit is contained in:
parent
98480cef9d
commit
051ff526b5
4 changed files with 22 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue