From: Stéphane Wirtel Date: Fri, 18 Oct 2019 07:14:18 +0000 (+0200) Subject: Doc: Add missing entry for functools.cached_property (GH-16803) X-Git-Tag: v3.9.0a1~163 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93b81e1fcbeb61c1b49ac2fa52c5a0dff929940b;p=thirdparty%2FPython%2Fcpython.git Doc: Add missing entry for functools.cached_property (GH-16803) --- diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 85351e10e699..fef712d2ab29 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -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 --