[issue40114] support maxsize argument for lru_cache's user_function option

Serhiy Storchaka report at bugs.python.org
Mon Mar 30 15:02:36 EDT 2020


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

You can use lru_cache(maxsize=128, typed=False)(user_function). lru_cache should support a function as an argument on if it is a single positional argument, this is the purpose. So you can write

@lru_cache
def func(...):
    ...

instead of

@lru_cache()
def func(...):
    ...

When you pass maxsize and typed you do not pass a function as an argument of lru_cache, you pass it as an argument of the decorator created by the lru_cache() call.

@lru_cache(maxsize=128, typed=False)
def func(...):
    ...

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40114>
_______________________________________


More information about the Python-bugs-list mailing list