PEP 218 Re: ANN: set-0.1 module available

Erik Max Francis max at alcyone.com
Mon May 20 23:34:39 EDT 2002


Huaiyu Zhu wrote:

> There need to be a different equal operator === (read as "always
> equal")
> that is used to compare keys.

No doubt such a proposal immediately would doom a revised PEP to
failure.

But that isn't the real issue.  The problem with hash/identity
collisions within a set is not that defining some metaequality is
problematic (which it is), it's that after the set has been created, a
mutable object can have its value changed, potentially even to something
that clashes with another object (mutable or not) in the same set.

Python, as far as I know, does not have any facilities for some kind of
implicit callback to containers that happens whenever an object changes
state, and so this means that once you've already placed mutable objects
in a set, they can change value willy nilly and completely break the
invariant of the set (namely that no two contained objects are
identical), essentially defeating the whole purpose for the set in the
first place.

This issue exists regardless of whether you come up with some concept of
metaequality or not; it will be present as long as the set can contain
mutable objects.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Who'd ever think it / Such a squalid little ending
\__/ The American and Florence, _Chess_
    Church / http://www.alcyone.com/pyos/church/
 A lambda calculus explorer in Python.



More information about the Python-list mailing list