Unexpected behaviour from the 'in' operator

Bernhard Herzog bh at intevation.de
Tue Feb 25 19:15:56 CET 2003

"Greg Ewing (using news.cis.dfn.de)" <me at privacy.net> writes:

> Rene Pijlman wrote:
> > If this is true I guess the equality operator could be optimized
> > to first check for identity, and only test non-identical objects
> > for equality.
> That would be a semantic change. Currently it's possible
> to create an object that is not == to itself; if the
> above optimisation were made, this wouldn't work
> reliably.

Well, Python 1.5.2 for one had that optimization. It's only with the
introduction of rich comparisons that it was dropped, IIRC, so python
2.0 probably has it as well. Nowadays this optimization is done in the
implementation of some object types such as strings.


Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                           http://www.mapit.de/

More information about the Python-list mailing list