Questions tagged [single-dispatch]

A language feature which allows different versions of a function to be called depending on the type of one argument. If decided by the types of multiple objects, it is multiple-dispatch.

34 questions
0
votes
0 answers

Howto singledispatch on class vs instance

This is essentially a syntactic sugar question, so if you do not approve of putting effort into that kind of thing read no further. Consider the following toy example which does not work: from functools import singledispatch class rows_or_cols: …
Paul Panzer
  • 51,835
  • 3
  • 54
  • 99
0
votes
0 answers

Update single-dispatch overload after decorating

Preface I'm using single dispatching with functools.singledispatch decorator like from functools import singledispatch from typing import Any @singledispatch def serialize(object_: Any) -> str: raise TypeError('Serialization for objects ' …
Azat Ibrakov
  • 9,998
  • 9
  • 38
  • 50
0
votes
1 answer

Polymorphism and Slicing with references

I didn't fully understand object slicing in C++. With the following example code two objects seem to receive the same processing, but polymorphism works for only one of them. I'm using references and one of the objects doesn't seem to be sliced. I…
Calimero
  • 161
  • 1
  • 8
-1
votes
1 answer

singledispatch on unpacked multiple arguments

I have a fancyfunction defined to do something to a single argument. I decorate it to become a generic function so that it knows what to do if it is given a tuple. from functools import singledispatch @singledispatch def fancyfunction(arg): …
Kit
  • 30,365
  • 39
  • 105
  • 149
1 2
3