Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Doc/library/functools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,20 @@ The :mod:`functools` module defines the following functions:
for the base ``object`` type, which means it is used if no better
implementation is found.

If an implementation registered to :term:`abstract base class`, virtual
subclasses will be dispatched to that implementation::

>>> from collections.abc import Mapping
>>> @fun.register
... def _(arg: Mapping, verbose=False):
... if verbose:
... print("Keys & Values")
... for key, value in arg.items():
... print(key, "=>", value)
...
>>> fun({"a": "b"})
a => b

To check which implementation will the generic function choose for
a given type, use the ``dispatch()`` attribute::

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Explicitly mention abc support in functools.singledispatch