Skip to content

Commit 93b81e1

Browse files
authored
Doc: Add missing entry for functools.cached_property (GH-16803)
1 parent f33c57d commit 93b81e1

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
@@ -683,6 +683,22 @@ than as a function returning a decorator. So both of these are now supported::
683683

684684
(Contributed by Raymond Hettinger in :issue:`36772`.)
685685

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

687703
gc
688704
--

0 commit comments

Comments
 (0)