Re: [Python-ideas] singledispatch for methods
![](https://secure.gravatar.com/avatar/1b83506807b97042ecdec21ae142562b.jpg?s=120&d=mm&r=g)
The motivation is the same as for functools.singledispatch ( https://www.python.org/dev/peps/pep-0443/) - provide generic methods. These are useful for visitor implementations that are cleaner than the visit_<class_name> approach typically used today (e.g. https://github.com/mbr/visitor). It is also useful for writing serialisers and encoders. The motivation is also that people keep using the method name munging approach (e.g. mypy) because functools.singledispatch only works on functions and not class methods. Cheers Tim On Wed, Mar 27, 2019 at 4:33 PM Michael Selik <michael.selik@gmail.com> wrote:
On Tue, Mar 26, 2019, 1:09 PM Tim Mitchell <tim.mitchell.chch@gmail.com> wrote:
Is it time to add singledispatch for methods to the core library?
What's the motivation for it, beyond the fact that it's possible?
Regarding jargon, aren't Python's instance methods are already single-dispatch, because they receive the instance as the first argument?
participants (1)
-
Tim Mitchell