From b6643b43c43007024febe5c8c02383dbb12f0518 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Tue, 2 May 2023 17:33:19 -0700 Subject: [PATCH 1/2] gh-104112: link from cached_property docs to method-caching FAQ --- Doc/library/functools.rst | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index 29cbc87bf66d12..66ed4b108c513b 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -110,18 +110,10 @@ The :mod:`functools` module defines the following functions: ``__slots__`` without including ``__dict__`` as one of the defined slots (as such classes don't provide a ``__dict__`` attribute at all). - If a mutable mapping is not available or if space-efficient key sharing - is desired, an effect similar to :func:`cached_property` can be achieved - by a stacking :func:`property` on top of :func:`cache`:: - - class DataSet: - def __init__(self, sequence_of_numbers): - self._data = sequence_of_numbers - - @property - @cache - def stdev(self): - return statistics.stdev(self._data) + If a mutable mapping is not available or if space-efficient key sharing is + desired, an effect similar to :func:`cached_property` can also be achieved by + stacking :func:`property` on top of :func:`lru_cache`. See + :ref:`faq-cache-method-calls` .. versionadded:: 3.8 From c2c2f6ca08426ae17350786d5694682560cd3755 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Wed, 3 May 2023 09:27:43 -0600 Subject: [PATCH 2/2] Update Doc/library/functools.rst Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> --- Doc/library/functools.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index 66ed4b108c513b..40f43f8b3519cd 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -113,7 +113,7 @@ The :mod:`functools` module defines the following functions: If a mutable mapping is not available or if space-efficient key sharing is desired, an effect similar to :func:`cached_property` can also be achieved by stacking :func:`property` on top of :func:`lru_cache`. See - :ref:`faq-cache-method-calls` + :ref:`faq-cache-method-calls` for more details on how this differs from :func:`cached_property`. .. versionadded:: 3.8