]> granicus.if.org Git - python/commitdiff
Doc: Add missing entry for functools.cached_property (GH-16803)
authorStéphane Wirtel <stephane@wirtel.be>
Fri, 18 Oct 2019 07:14:18 +0000 (09:14 +0200)
committerGitHub <noreply@github.com>
Fri, 18 Oct 2019 07:14:18 +0000 (09:14 +0200)
Doc/whatsnew/3.8.rst

index 85351e10e69944675886a009c8e184bb833de0d0..fef712d2ab2960cf47c16602715a1b129edb4c16 100644 (file)
@@ -683,6 +683,22 @@ than as a function returning a decorator.  So both of these are now supported::
 
 (Contributed by Raymond Hettinger in :issue:`36772`.)
 
+Added a new :func:`functools.cached_property` decorator, for computed properties
+cached for the life of the instance. ::
+
+   import functools
+   import statistics
+
+   class Dataset:
+      def __init__(self, sequence_of_numbers):
+         self.data = sequence_of_numbers
+
+      @functools.cached_property
+      def variance(self):
+         return statistics.variance(self.data)
+
+(Contributed by Carl Meyer in :issue:`21145`)
+
 
 gc
 --