mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
gh-104112: link from cached_property docs to method-caching FAQ (#104113)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
parent
46361bb843
commit
fa86a77589
1 changed files with 4 additions and 12 deletions
|
@ -110,18 +110,10 @@ The :mod:`functools` module defines the following functions:
|
||||||
``__slots__`` without including ``__dict__`` as one of the defined slots
|
``__slots__`` without including ``__dict__`` as one of the defined slots
|
||||||
(as such classes don't provide a ``__dict__`` attribute at all).
|
(as such classes don't provide a ``__dict__`` attribute at all).
|
||||||
|
|
||||||
If a mutable mapping is not available or if space-efficient key sharing
|
If a mutable mapping is not available or if space-efficient key sharing is
|
||||||
is desired, an effect similar to :func:`cached_property` can be achieved
|
desired, an effect similar to :func:`cached_property` can also be achieved by
|
||||||
by a stacking :func:`property` on top of :func:`cache`::
|
stacking :func:`property` on top of :func:`lru_cache`. See
|
||||||
|
:ref:`faq-cache-method-calls` for more details on how this differs from :func:`cached_property`.
|
||||||
class DataSet:
|
|
||||||
def __init__(self, sequence_of_numbers):
|
|
||||||
self._data = sequence_of_numbers
|
|
||||||
|
|
||||||
@property
|
|
||||||
@cache
|
|
||||||
def stdev(self):
|
|
||||||
return statistics.stdev(self._data)
|
|
||||||
|
|
||||||
.. versionadded:: 3.8
|
.. versionadded:: 3.8
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue