Skip to content

Commit

Permalink
Doc: Add missing entry for functools.cached_property (GH-16803)
Browse files Browse the repository at this point in the history
(cherry picked from commit 93b81e1)

Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
  • Loading branch information
miss-islington and matrixise committed Oct 18, 2019
1 parent c615db6 commit 380d443
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Doc/whatsnew/3.8.rst
Expand Up @@ -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
--
Expand Down

0 comments on commit 380d443

Please sign in to comment.