[New-bugs-announce] [issue42781] functools.cached_property docs should explain that it is non-overriding

Luciano Ramalho report at bugs.python.org
Tue Dec 29 13:12:58 EST 2020


New submission from Luciano Ramalho <luciano at ramalho.org>:

functools.cached_property is a great addition to the standard library, thanks!

However, the docs do not say that @cached_property produces a non-overriding descriptor, in contrast with @property.

If a user replaces a @property with a @cached_property, her code may or may not break depending on the existence of an instance attribute with the same name as the decorated method. This is surprising and may affect correctness, so it deserves even more attention than the possible performance loss already mentioned in the docs, related to the shared-dict optimization.

In the future, perhaps we can add an argument to @cached_property to optionally make it produce overriding descriptors.

----------
assignee: docs at python
components: Documentation
messages: 384019
nosy: docs at python, ramalho
priority: normal
severity: normal
status: open
title: functools.cached_property docs should explain that it is non-overriding
versions: Python 3.10, Python 3.8, Python 3.9

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


More information about the New-bugs-announce mailing list