An interesting idea, however from my point of view in methoddispatch there
is no dispatching on the self argument at all.
Overriding methods simply allows your subclass to have a different dispatch
table for a method than the super class. This happens when the class is
created, not when the function is called.
When the method is called it is single-dispatched on the (single) argument
after self using the dispatch table for the class of the method.
On 17 October 2016 at 11:53, Aric Coady <aric.co...@gmail.com> wrote:
> On Oct 14, 2016, at 8:49 AM, python-dev-requ...@python.org wrote:
> Date: Fri, 14 Oct 2016 14:11:18 +1300
> From: Tim Mitchell <tim.mitch...@leapfrog3d.com>
> It would be nice if the @singledispatch decorator worked on instance
> I have a reference implementation on pypi that does this (
> You might be interested in this thread from my multimethod library:
> https://bitbucket.org/coady/multimethod/issues/2/. It was a feature
> request for multiple dispatch to work on instance methods. I implemented a
> variation where the initial self argument still contributed to the dispatch.
> I think the same reasoning would apply in the single dispatch case: that
> it’s not obvious the “dispatch” would occur once on the self argument to
> find the method, and then again on the “first” argument. Especially since
> Py3 did away with bound methods, so you can call a method through its class
> and explicitly supply self as the first argument.
Python-Dev mailing list