Skip to content

Commit c3c2ec5

Browse files
schinckeltimgraham
authored andcommitted
Refs #30278 -- Doc'd behavior of del on an unaccessed cached_property.
Thanks to Curtis Maloney for the description of the problem.
1 parent ad72895 commit c3c2ec5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/ref/utils.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
473473
# set a value manually, that will persist on the instance until cleared
474474
person.friends = ["Huckleberry Finn", "Tom Sawyer"]
475475

476+
Because of the way the `descriptor protocol
477+
<descriptor-invocation>`_ works, using ``del`` (or ``delattr``) on a
478+
``cached_property`` that hasn't been accessed raises ``AttributeError``.
479+
476480
As well as offering potential performance advantages, ``@cached_property``
477481
can ensure that an attribute's value does not change unexpectedly over the
478482
life of an instance. This could occur with a method whose computation is

0 commit comments

Comments
 (0)