Skip to content

Commit 666a2a8

Browse files
gh-143535: Document dispatch behavior of singledispatchmethod
1 parent 888d101 commit 666a2a8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Doc/library/functools.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,11 @@ The :mod:`functools` module defines the following functions:
679679
decorator. When defining a method using ``@singledispatchmethod``, note
680680
that the dispatch happens on the type of the first non-*self* or non-*cls*
681681
argument::
682-
682+
.. note::
683+
``singledispatchmethod`` dispatches the first argument during call
684+
time irrespective of whether the method is bound or unbound, as a result,
685+
``x.f(a) != C.f(x, a)``.The behavior is intentional and required to support correct dispatch for
686+
``staticmethod`` and ``classmethod``.
683687
class Negator:
684688
@singledispatchmethod
685689
def neg(self, arg):

0 commit comments

Comments
 (0)