[Python-checkins] Doc: Add missing entry for functools.cached_property (GH-16803)
Miss Islington (bot)
webhook-mailer at python.org
Fri Oct 18 03:21:11 EDT 2019
https://github.com/python/cpython/commit/380d443a6ac73cb4719d86fd5781544630bcec5e
commit: 380d443a6ac73cb4719d86fd5781544630bcec5e
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-10-18T00:21:05-07:00
summary:
Doc: Add missing entry for functools.cached_property (GH-16803)
(cherry picked from commit 93b81e1fcbeb61c1b49ac2fa52c5a0dff929940b)
Co-authored-by: Stéphane Wirtel <stephane at wirtel.be>
files:
M Doc/whatsnew/3.8.rst
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index e1388e2169f47..ef4209f9db499 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -685,6 +685,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
--
More information about the Python-checkins
mailing list