| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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 | ||
@@ -418,7 +424,7 @@ The :mod:`functools` module defines the following functions: | |||
| 418 | 424 | like normal functions, are handled as descriptors). | |
| 419 | 425 | ||
| 420 | 426 | When *func* is a descriptor (such as a normal Python function, | |
| 421 | - :func:`classmethod`, :func:`staticmethod`, :func:`abstractmethod` or | ||
| 427 | + :func:`classmethod`, :func:`staticmethod`, :func:`~abc.abstractmethod` or | ||
| 422 | 428 | another instance of :class:`partialmethod`), calls to ``__get__`` are | |
| 423 | 429 | delegated to the underlying descriptor, and an appropriate | |
| 424 | 430 | :ref:`partial object<partial-objects>` returned as the result. | |
@@ -499,7 +505,10 @@ The :mod:`functools` module defines the following functions: | |||
| 499 | 505 | ... print("Let me just say,", end=" ") | |
| 500 | 506 | ... print(arg) | |
| 501 | 507 | ||
| 502 | - To add overloaded implementations to the function, use the :func:`register` | ||
| 508 | + .. method:: singledispatch.register() | ||
| 509 | + :no-typesetting: | ||
| 510 | + | ||
| 511 | + To add overloaded implementations to the function, use the :func:`!register` | ||
| 503 | 512 | attribute of the generic function, which can be used as a decorator. For | |
| 504 | 513 | functions annotated with types, the decorator will infer the type of the | |
| 505 | 514 | first argument automatically:: | |
@@ -565,14 +574,14 @@ The :mod:`functools` module defines the following functions: | |||
| 565 | 574 | runtime impact. | |
| 566 | 575 | ||
| 567 | 576 | To enable registering :term:`lambdas<lambda>` and pre-existing functions, | |
| 568 | - the :func:`register` attribute can also be used in a functional form:: | ||
| 577 | + the :func:`~singledispatch.register` attribute can also be used in a functional form:: | ||
| 569 | 578 | ||
| 570 | 579 | >>> def nothing(arg, verbose=False): | |
| 571 | 580 | ... print("Nothing.") | |
| 572 | 581 | ... | |
| 573 | 582 | >>> fun.register(type(None), nothing) | |
| 574 | 583 | ||
| 575 | - The :func:`register` attribute returns the undecorated function. This | ||
| 584 | + The :func:`~singledispatch.register` attribute returns the undecorated function. This | ||
| 576 | 585 | enables decorator stacking, :mod:`pickling<pickle>`, and the creation | |
| 577 | 586 | of unit tests for each variant independently:: | |
| 578 | 587 | ||
@@ -650,10 +659,10 @@ The :mod:`functools` module defines the following functions: | |||
| 650 | 659 | .. versionadded:: 3.4 | |
| 651 | 660 | ||
| 652 | 661 | .. versionchanged:: 3.7 | |
| 653 | - The :func:`register` attribute now supports using type annotations. | ||
| 662 | + The :func:`~singledispatch.register` attribute now supports using type annotations. | ||
| 654 | 663 | ||
| 655 | 664 | .. versionchanged:: 3.11 | |
| 656 | - The :func:`register` attribute now supports | ||
| 665 | + The :func:`~singledispatch.register` attribute now supports | ||
| 657 | 666 | :class:`typing.Union` as a type annotation. | |
| 658 | 667 | ||
| 659 | 668 | ||
@@ -783,7 +792,7 @@ The :mod:`functools` module defines the following functions: | |||
| 783 | 792 | 'Docstring' | |
| 784 | 793 | ||
| 785 | 794 | Without the use of this decorator factory, the name of the example function | |
| 786 | - would have been ``'wrapper'``, and the docstring of the original :func:`example` | ||
| 795 | + would have been ``'wrapper'``, and the docstring of the original :func:`!example` | ||
| 787 | 796 | would have been lost. | |
| 788 | 797 | ||
| 789 | 798 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,6 @@ Doc/extending/extending.rst | |||
| 15 | 15 | Doc/library/ast.rst | |
| 16 | 16 | Doc/library/asyncio-extending.rst | |
| 17 | 17 | Doc/library/email.charset.rst | |
| 18 | - Doc/library/functools.rst | ||
| 19 | 18 | Doc/library/http.cookiejar.rst | |
| 20 | 19 | Doc/library/http.server.rst | |
| 21 | 20 | Doc/library/importlib.rst | |
| Back | FazBrowse Home | New Git URL |
0 commit comments