Are there any list comparison optimizations in Python?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Fri Nov 16 15:33:18 EST 2001


Fri, 16 Nov 2001 09:35:40 +0100, Skip Montanaro <skip at pobox.com> pisze:

> 
>     Huaiyu> So my question really is this: Is there any major practical use
>     Huaiyu> for an object to be unequal to itself?  Would it be better to
>     Huaiyu> just define (a==b) to take a shortcut of (a is b), always?
> 
> The "is" operator is defined to just do pointer comparisons.  Here are just
> three different ways to generate objects that are equal but not "is":

The question was whether (a==b) should check (a is b) first and
perform the real value test only when (a is not b), returning 1
otherwise.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^
QRCZAK



More information about the Python-list mailing list