Message384019
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. |
|
Date |
User |
Action |
Args |
2020-12-29 18:12:58 | ramalho | set | recipients:
+ ramalho, docs@python |
2020-12-29 18:12:58 | ramalho | set | messageid: <1609265578.67.0.475985633003.issue42781@roundup.psfhosted.org> |
2020-12-29 18:12:58 | ramalho | link | issue42781 messages |
2020-12-29 18:12:58 | ramalho | create | |
|