"/a" is not "/a" ?

Albert Hopkins marduk at letterboxes.org
Sat Mar 7 03:11:02 EST 2009


On Sat, 2009-03-07 at 03:07 -0500, Albert Hopkins wrote:
> On Fri, 2009-03-06 at 23:57 -0800, Paul Rubin wrote:
> > alex23 <wuwei23 at gmail.com> writes:
> > > But _you_ only _just_ stated "It does have some (generally small)
> > > performance ramifications as
> > > well" and provided timing examples to show it. Without qualification.
> > 
> > The performance difference can be large if the objects are (for
> > example) long lists.
> 
> I would think (not having looked) that the implementation of == would
> first check for identity (for performance reasons)... but then that lead
> me to ask: can an object be identical but not equal to itself?

... answered my own question


class Foo:
    def __eq__(self, b):
        return False

>>> x == Foo()
>>> x is x
--> True

>>> x == x
--> False





More information about the Python-list mailing list