Skip to content

Commit f74a61c

Browse files
authored
add index entries and anchors for cache_info, cache_clear and register
1 parent 8c11b08 commit f74a61c

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

Doc/library/functools.rst

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ The :mod:`functools` module defines the following functions:
151151
.. decorator:: lru_cache(user_function)
152152
lru_cache(maxsize=128, typed=False)
153153

154+
.. method:: cache_info()
155+
:no-typesetting:
156+
157+
158+
.. method:: cache_clear()
159+
:no-typesetting:
160+
161+
154162
Decorator to wrap a function with a memoizing callable that saves up to the
155163
*maxsize* most recent calls. It can save time when an expensive or I/O bound
156164
function is periodically called with the same arguments.
@@ -200,11 +208,11 @@ The :mod:`functools` module defines the following functions:
200208
has no effect.
201209

202210
To help measure the effectiveness of the cache and tune the *maxsize*
203-
parameter, the wrapped function is instrumented with a :func:`!cache_info`
211+
parameter, the wrapped function is instrumented with a :func:`cache_info`
204212
function that returns a :term:`named tuple` showing *hits*, *misses*,
205213
*maxsize* and *currsize*.
206214

207-
The decorator also provides a :func:`!cache_clear` function for clearing or
215+
The decorator also provides a :func:`cache_clear` function for clearing or
208216
invalidating the cache.
209217

210218
The original underlying function is accessible through the
@@ -485,6 +493,9 @@ The :mod:`functools` module defines the following functions:
485493

486494
.. decorator:: singledispatch
487495

496+
.. method:: register()
497+
:no-typesetting:
498+
488499
Transform a function into a :term:`single-dispatch <single
489500
dispatch>` :term:`generic function`.
490501

@@ -499,7 +510,7 @@ The :mod:`functools` module defines the following functions:
499510
... print("Let me just say,", end=" ")
500511
... print(arg)
501512

502-
To add overloaded implementations to the function, use the :func:`!register`
513+
To add overloaded implementations to the function, use the :func:`register`
503514
attribute of the generic function, which can be used as a decorator. For
504515
functions annotated with types, the decorator will infer the type of the
505516
first argument automatically::
@@ -565,14 +576,14 @@ The :mod:`functools` module defines the following functions:
565576
runtime impact.
566577

567578
To enable registering :term:`lambdas<lambda>` and pre-existing functions,
568-
the :func:`!register` attribute can also be used in a functional form::
579+
the :func:`register` attribute can also be used in a functional form::
569580

570581
>>> def nothing(arg, verbose=False):
571582
... print("Nothing.")
572583
...
573584
>>> fun.register(type(None), nothing)
574585

575-
The :func:`!register` attribute returns the undecorated function. This
586+
The :func:`register` attribute returns the undecorated function. This
576587
enables decorator stacking, :mod:`pickling<pickle>`, and the creation
577588
of unit tests for each variant independently::
578589

@@ -650,10 +661,10 @@ The :mod:`functools` module defines the following functions:
650661
.. versionadded:: 3.4
651662

652663
.. versionchanged:: 3.7
653-
The :func:`!register` attribute now supports using type annotations.
664+
The :func:`register` attribute now supports using type annotations.
654665

655666
.. versionchanged:: 3.11
656-
The :func:`!register` attribute now supports
667+
The :func:`register` attribute now supports
657668
:class:`typing.Union` as a type annotation.
658669

659670

0 commit comments

Comments
 (0)