
Antoine Pitrou schrieb am 16.08.2014 um 15:34:
Le 15/08/2014 14:01, Guido van Rossum a écrit :
Please do write about non-toy examples!
Are you looking for examples using the multipledispatch library, or multiple dispatch in general?
As for multiple dispatch in general, Numba uses something which is morally one in order to select the right specialization of, say, an operator (for example to choose amongst '+ between int and int', '+ between numpy.datetime64 and numpy.timedelta64', '+ between numpy.timedelta64 and numpy.timedelta64', etc.).
Similar for Cython's "fused types", i.e. compile time generics. It generates specialised function implementations for a cross product of the type sets used in the signature and then calls the right specialisation based on the input types at runtime, when called from Python code. Understands input buffer types and C types in signatures, though, so it's a bit more complex than the "average Python generic function dispatch" (same applies to Numba, I guess). Stefan