[New-bugs-announce] [issue41280] lru_cache on 0-arity functions should default to maxsize=None

Tom Forbes report at bugs.python.org
Sat Jul 11 18:46:12 EDT 2020


New submission from Tom Forbes <tom at tomforb.es>:

`functools.lru_cache` has a maxsize=128 default for all functions.

If a function has no arguments then this maxsize default is redundant and should be set to `maxsize=None`:

```
@functools.lru_cache()
def function_with_no_args():
    pass
```

Currently you need to add `maxsize=None` manually, and ensure that it is also updated if you alter the function to add arguments.

----------
components: Library (Lib)
messages: 373542
nosy: Tom Forbes
priority: normal
severity: normal
status: open
title: lru_cache on 0-arity functions should default to maxsize=None
type: performance
versions: Python 3.10

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


More information about the New-bugs-announce mailing list