overloading on type?

Neelakantan Krishnaswami neelk at alum.mit.edu
Fri Feb 16 11:11:03 EST 2001


On 15 Feb 2001 05:20:46 GMT, Nathan Froyd <froydnj at rose-hulman.edu> wrote:
>In article <982149618.95754 at master.nyc.kbcfp.com>, Burkhard Kloss wrote:
>>Maybe I'm just having a conceptual block here as a result of my upbringing
>>(I'm a longtime and unrepentant C++ user and lover), but surely in a
>>language as nice as python there must be a better way to do this? :)
>>Overloading obviously doesn't fit into the conceptual framework of the
>>language.
>
>You might try Multimethod.py:
>
>http://www.sff.net/people/neelk/open-source/
>
> It might not do *exactly* what you want (I don't know if you can
> specialize on built-in datatypes and I don't know what the speed is
> like), but it's probably a good starting point.

Yes, you can specialize on C types. Unlike C++ overloading, this does
real multiple dispatch -- the overloading is resolved based on the
*runtime* class of the methods, not the static type. Thes performance
overhead is about what you'd expect from wrapping something with a
__call__ method.


Neel



More information about the Python-list mailing list