Skip to content

Commit 380d443

Browse files
Doc: Add missing entry for functools.cached_property (GH-16803)
(cherry picked from commit 93b81e1) Co-authored-by: Stéphane Wirtel <[email protected]>
1 parent c615db6 commit 380d443

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Doc/whatsnew/3.8.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,22 @@ than as a function returning a decorator. So both of these are now supported::
685685

686686
(Contributed by Raymond Hettinger in :issue:`36772`.)
687687

688+
Added a new :func:`functools.cached_property` decorator, for computed properties
689+
cached for the life of the instance. ::
690+
691+
import functools
692+
import statistics
693+
694+
class Dataset:
695+
def __init__(self, sequence_of_numbers):
696+
self.data = sequence_of_numbers
697+
698+
@functools.cached_property
699+
def variance(self):
700+
return statistics.variance(self.data)
701+
702+
(Contributed by Carl Meyer in :issue:`21145`)
703+
688704

689705
gc
690706
--

0 commit comments

Comments
 (0)