You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
singledispatchmethod dispatches on first argument to instance-bindable method called from class level #143535
singledispatch and singledispatchmethod don't analyze and adapt argument semantics to the registered callable type, which makes them very nice and simple.
_singledispatchmethod_get always dispatches on args[0] regardless of whether it's bound or unbound, and if it didn't, that would break descriptor support; this facet is crucial for staticmethod (and classmethod) dispatches to work:
changed the title [-]`singledispatchmethod` dispatches on the `self` argument what invoked from class level[/-][+]`singledispatchmethod` dispatches on the `self` argument when invoked from class level[/+]on Jan 8, 2026
changed the title [-]`singledispatchmethod` dispatches on the `self` argument when invoked from class level[/-][+]Document that `singledispatchmethod` dispatches on the `self` argument when invoked from class level[/+]on Jan 9, 2026
I have prepared a doc fix and raising a PR in which I have documented the behaviour that singledispatchmethod always dispatches first argument during call, which fails the regular behaviour of x.f(a)=c.f(a).
changed the title [-]Document that `singledispatchmethod` dispatches on the `self` argument when invoked from class level[/-][+]`singledispatchmethod` dispatches on bound argument when invoked from class level[/+]on Feb 8, 2026
changed the title [-]`singledispatchmethod` dispatches on bound argument when invoked from class level[/-][+]`singledispatchmethod` dispatches on first argument to instance-bindable method called from class level[/+]on Feb 8, 2026
Activity
[-]`singledispatchmethod` dispatches on the `self` argument what invoked from class level[/-][+]`singledispatchmethod` dispatches on the `self` argument when invoked from class level[/+][-]`singledispatchmethod` dispatches on the `self` argument when invoked from class level[/-][+]Document that `singledispatchmethod` dispatches on the `self` argument when invoked from class level[/+]pythongh-143535: Document dispatch behavior of singledispatchmethod
priyanshu2282-cyber commentedon Jan 9, 2026
I have prepared a doc fix and raising a PR in which I have documented the behaviour that
singledispatchmethodalways dispatches first argument during call, which fails the regular behaviour ofx.f(a)=c.f(a).pythongh-143535: Move singledispatchmethod note outside example block
pythongh-143535: Clarify dispatch semantics of singledispatchmethod
pythongh-143535: Fix indentation in singledispatchmethod docs
[-]Document that `singledispatchmethod` dispatches on the `self` argument when invoked from class level[/-][+]`singledispatchmethod` dispatches on bound argument when invoked from class level[/+]johnslavik commentedon Feb 8, 2026
I was wrong. This can be fixed, 100% low-risk.
[-]`singledispatchmethod` dispatches on bound argument when invoked from class level[/-][+]`singledispatchmethod` dispatches on first argument to instance-bindable method called from class level[/+]gh-143535: Dispatch on the second argument if generic method is insta…
ambv commentedon Feb 24, 2026
Reclassifying as feature for backward compat safety. Fixed by #144615.
pythongh-143535: Dispatch on the second argument if generic method is…
pythongh-143535: Dispatch on the second argument if generic method is…