At 07:58 AM 4/8/2006 -0700, Guido van Rossum wrote:
>On 4/8/06, Phillip J. Eby <[EMAIL PROTECTED]> wrote:
> > By the way, my rewrite of dominates() actually had a bug in it also, as did
> > your original.  Yours used an 'is' to compare the tuple signatures where it
> > should've used ==, and mine checked individual types with 'is' instead of
> > comparing the entire tuple with ==.  Instead of:
> >
> >      all(d is not s and issubclass(d,s) for d,s in zip(dom, sub))
> >
> > I should've written:
> >
> >      dom != sub and all(issubclass(d,s) for d,s in zip(dom, sub))
>
>But since d and s are types, and AFAIK == for types is defined as
>'is', it doesn't matter?

It matters that the comparison is moved out of the loop, because before it 
was basically was saying that a pair of signatures were ambiguous if any of 
the types were the same!  That was the bug in my version.  The bug in your 
version was that there was no way for dom to be 'is' sub, because they were 
tuples.

Oh wait -- your version was okay, because the only case where dom==sub in 
your implementation is the case where you compared a signature against 
itself.  My intuition failed me here because in RuleDispatch it *is* 
possible to register multiple methods with the same signature, so an 'is' 
comparison would be inadequate, and a dominance comparison would require an 
equality test.

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to