[Python-Dev] object equality vs identity, in and dicts idioms and speed
Samuele Pedroni
Samuele Pedroni" <pedroni@inf.ethz.ch
Thu, 3 Jan 2002 17:51:15 +0100
PS: I know that equality for user classes defaults to identity.
But I'm obviously interested to the case when equality has
been possibly redefined and I still need identity.
Thanks.
----- Original Message -----
From: Samuele Pedroni <pedronis@bluewin.ch>
To: <python-dev@python.org>
Sent: Thursday, January 03, 2002 5:43 PM
Subject: [Python-Dev] object equality vs identity, in and dicts idioms and
speed
> Hi,
>
> [Ok this is maybe more a comp.lang.python thing
> but ...]
>
> If I'm correct
> dictionaries are based on equality and so the "in" operator.
>
> AFAIK if I'm interested in a dictionary working on identity
> I should wrap my objects ...
>
> Now what is the fastest idiom equivalent to:
>
> obj in list
>
> when I'm interested in identity (is) and not equality?
>
> That was the comp.lang.python part, now
> my impression is that in any case when I'm interested
> in identity and not equality I have to workaround,
> that means I will never directly have the performace of the
> equality idioms. Although my experience say that the
> equality case is the most common, I wonder whether
> some directy support for the identity case isn't worth,
> because it is rare but typically then you would like some
> speed. [Yes, I have some concrete context but this is long
> so unless strictly requested ...]
>
> Am I missing something? Opinions.
>
> regards.
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
>