@@ -199,12 +199,18 @@ The :mod:`functools` module defines the following functions:
199
199
and *typed *. This is for information purposes only. Mutating the values
200
200
has no effect.
201
201
202
+ .. method :: lru_cache.cache_info()
203
+ :no-typesetting:
204
+
202
205
To help measure the effectiveness of the cache and tune the *maxsize *
203
- parameter, the wrapped function is instrumented with a :func: `cache_info `
206
+ parameter, the wrapped function is instrumented with a :func: `! cache_info `
204
207
function that returns a :term: `named tuple ` showing *hits *, *misses *,
205
208
*maxsize * and *currsize *.
206
209
207
- The decorator also provides a :func: `cache_clear ` function for clearing or
210
+ .. method :: lru_cache.cache_clear()
211
+ :no-typesetting:
212
+
213
+ The decorator also provides a :func: `!cache_clear ` function for clearing or
208
214
invalidating the cache.
209
215
210
216
The original underlying function is accessible through the
@@ -284,9 +290,9 @@ The :mod:`functools` module defines the following functions:
284
290
class decorator supplies the rest. This simplifies the effort involved
285
291
in specifying all of the possible rich comparison operations:
286
292
287
- The class must define one of :meth: `__lt__ `, :meth: `__le__ `,
288
- :meth: `__gt__ `, or :meth: `__ge__ `.
289
- In addition, the class should supply an :meth: `__eq__ ` method.
293
+ The class must define one of :meth: `~object. __lt__ `, :meth: `~object. __le__ `,
294
+ :meth: `~object. __gt__ `, or :meth: `~object. __ge__ `.
295
+ In addition, the class should supply an :meth: `~object. __eq__ ` method.
290
296
291
297
For example::
292
298
@@ -369,7 +375,7 @@ The :mod:`functools` module defines the following functions:
369
375
like normal functions, are handled as descriptors).
370
376
371
377
When *func * is a descriptor (such as a normal Python function,
372
- :func: `classmethod `, :func: `staticmethod `, :func: `abstractmethod ` or
378
+ :func: `classmethod `, :func: `staticmethod `, :func: `~abc. abstractmethod ` or
373
379
another instance of :class: `partialmethod `), calls to ``__get__ `` are
374
380
delegated to the underlying descriptor, and an appropriate
375
381
:ref: `partial object<partial-objects> ` returned as the result.
@@ -447,7 +453,10 @@ The :mod:`functools` module defines the following functions:
447
453
... print("Let me just say,", end=" ")
448
454
... print(arg)
449
455
450
- To add overloaded implementations to the function, use the :func: `register `
456
+ .. method :: singledispatch.register()
457
+ :no-typesetting:
458
+
459
+ To add overloaded implementations to the function, use the :func: `!register `
451
460
attribute of the generic function, which can be used as a decorator. For
452
461
functions annotated with types, the decorator will infer the type of the
453
462
first argument automatically::
@@ -513,14 +522,14 @@ The :mod:`functools` module defines the following functions:
513
522
runtime impact.
514
523
515
524
To enable registering :term: `lambdas<lambda> ` and pre-existing functions,
516
- the :func: `register ` attribute can also be used in a functional form::
525
+ the :func: `~singledispatch. register ` attribute can also be used in a functional form::
517
526
518
527
>>> def nothing(arg, verbose=False):
519
528
... print("Nothing.")
520
529
...
521
530
>>> fun.register(type(None), nothing)
522
531
523
- The :func: `register ` attribute returns the undecorated function. This
532
+ The :func: `~singledispatch. register ` attribute returns the undecorated function. This
524
533
enables decorator stacking, :mod: `pickling<pickle> `, and the creation
525
534
of unit tests for each variant independently::
526
535
@@ -598,10 +607,10 @@ The :mod:`functools` module defines the following functions:
598
607
.. versionadded :: 3.4
599
608
600
609
.. versionchanged :: 3.7
601
- The :func: `register ` attribute now supports using type annotations.
610
+ The :func: `~singledispatch. register ` attribute now supports using type annotations.
602
611
603
612
.. versionchanged :: 3.11
604
- The :func: `register ` attribute now supports :data: `types.UnionType `
613
+ The :func: `~singledispatch. register ` attribute now supports :data: `types.UnionType `
605
614
and :data: `typing.Union ` as type annotations.
606
615
607
616
@@ -731,7 +740,7 @@ The :mod:`functools` module defines the following functions:
731
740
'Docstring'
732
741
733
742
Without the use of this decorator factory, the name of the example function
734
- would have been ``'wrapper' ``, and the docstring of the original :func: `example `
743
+ would have been ``'wrapper' ``, and the docstring of the original :func: `! example `
735
744
would have been lost.
736
745
737
746
0 commit comments