Re:MultiMethods for Python
by tomjen3 on Saturday June 26, 2010 @08:37PM
(#1464596)
It is true that one of the advantages of overloaded methods is that the cost is payed at compiler time, but it does also limit its flexibility, since it can only dispatch based on the information available at compile time (this isn't enough to implement oop polymorphism for example, except if you know no derived class override the method).
Python makes this much more complicated, because it doesn't have types (actually all the variables have dynamic types, so the type of a variable depends on what value it has) - and it is interpretated, so there isn't a compile step where it could resolve something like this.
Oh and usually multimethods dispatch based on the actual type of _multiple_ arguments, not just one.
Python makes this much more complicated, because it doesn't have types (actually all the variables have dynamic types, so the type of a variable depends on what value it has) - and it is interpretated, so there isn't a compile step where it could resolve something like this.
Oh and usually multimethods dispatch based on the actual type of _multiple_ arguments, not just one.