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.
On Wed, Mar 27, 2019 at 4:33 PM Michael Selik email@example.com wrote:
On Tue, Mar 26, 2019, 1:09 PM Tim Mitchell firstname.lastname@example.org 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?