Parametric Polymorphism

Catalin Marinas catalin.marinas at gmail.com
Tue Sep 27 05:24:31 EDT 2005


Pierre Barbier de Reuille <pierre.barbier at cirad.fr> wrote:
> Now suppose you have two classes A and B, B subclassing A.
> If you define :
>
> @method(A)
> def myfct(f):
>   do_something_with_f
>
> Then, you want it to work with any object of type B ... but with either
> Guido's or this implementation, it won't ! The problem is much more
> complex and cannot be solved in constant (or even linear) time. What I
> read concerning Lisp is they use a cache to optimize method
> resolution.

Yes, I realised that subclass/superclass relations cannot be quicly
solved. I haven't looked at the Lisp implementation and can't comment
on it. I suspect that using something like splay trees to re-adjust
the search graph at every search would speed things up a bit.

-- 
Catalin



More information about the Python-list mailing list