Semantics of ==

Terry Reedy tjreedy at udel.edu
Wed Mar 17 17:33:18 CET 2004


"Axel Boldt" <axelboldt at yahoo.com> wrote in message
news:40200384.0403170657.5c81a456 at posting.google.com...
> That definition doesn't seem to fully specify equality of list values:
> to determine whether s==w, I first note that they both have length 2
> and both have 1 as their first element, the second element of s is a
> pointer to s, the second element of w is a two-element list, with
> first element 1 and second element a pointer to w. So now I have to
> determine whether s is equal to the two element list with first
> element 1 and second element a pointer to w. They both have two
> elements, they both share the first element 1, the second element of s
> is a pointer to s, the second element of the other list is a pointer
> to w. Now I'm back where I started: I have to test whether s==w. So
> the definition in the language reference is circular and both
> conclusions s==w and s!=w are consistent with it. I hope that the
> actual result received, i.e. s==w, is not implementation dependent?

You could try old versions if you have access back far enough ;-).

I vaguely remember a discussion on PyDev list, some years ago, of
'equality' of infinite recursive structures.  I believe there was a change
in the direction of simplicity and robustness to the current algorithm from
a more ambitious algorithm that might have detected s != w -- but which
sometimes had problems.  For dicts at least, a finite printout (instead of
infinite looping requiring a keyboard interrupt) is an innovation since
1.4.

Terry J. Reedy







More information about the Python-list mailing list