[issue36772] Let lru_cache be used as a decorator with no arguments

Eric V. Smith report at bugs.python.org
Thu May 2 04:18:16 EDT 2019


Eric V. Smith <eric at trueblade.com> added the comment:

The 90% use case with dataclasses is satisfied with just "@dataclass", and perhaps the target user there is less sophisticated.

But the main difference between @dataclass and @lru_cache is that all of the parameters to @dataclass are keyword-only. Which I did because they are mostly all booleans, and "@dataclass(True, False, True)" isn't very helpful.

That's not the case with @lru_cache. Whether that makes a difference for this issue in particular, I'm not sure.

I agree that this violates "only one way to do it". But I haven't seen anyone use "@dataclass()", and I've also never seen anyone be confused by the fact that once you want parameters, you change to using parens. For the dataclass case, I think that working both ways has been helpful.

----------

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


More information about the Python-bugs-list mailing list