diff options
| author | Matthew Schinckel <matt@schinckel.net> | 2019-03-30 23:59:03 +1030 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-03-30 09:29:23 -0400 |
| commit | f14170406c8a1f97eacbc38830a7af62a17a31dd (patch) | |
| tree | 5ab1b9b6a97ed3626b740adef29657d0ac4e1e1f /docs | |
| parent | 4a7bbace6bdfc3a4083df83bca3c456efbd66a53 (diff) | |
[2.2.x] Refs #30278 -- Doc'd behavior of del on an unaccessed cached_property.
Thanks to Curtis Maloney for the description of the problem.
Backport of c3c2ec54f59428cdf0a35abce594fd2ada35c209 from master
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/utils.txt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index 06de2731ec..919c6d60e8 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -485,6 +485,10 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004 # set a value manually, that will persist on the instance until cleared person.friends = ["Huckleberry Finn", "Tom Sawyer"] + Because of the way the `descriptor protocol + <descriptor-invocation>`_ works, using ``del`` (or ``delattr``) on a + ``cached_property`` that hasn't been accessed raises ``AttributeError``. + As well as offering potential performance advantages, ``@cached_property`` can ensure that an attribute's value does not change unexpectedly over the life of an instance. This could occur with a method whose computation is |
