PEP 218 Re: ANN: set-0.1 module available

Erik Max Francis max at alcyone.com
Fri May 17 18:42:31 EDT 2002


Fernando Pérez wrote:

> I beg to differ. Mathematically, there's nothing in the idea of a set
> that
> makes it immutable. I know that Python is not a mathematics-only
> language,
> but much of the cleanliness of its design does come from following
> abstract
> ideas as much as is reasonable. And enforcing immutability on a set is
> one
> hell of a breakage for an object as basic to many mathematical ideas
> as a set
> is.

Sure, but when translating mathematical concepts to programming,
practicality always gets in the way.  A dictionary, for instance, in
essence just a function which maps a set into another.  The practical
measures of dealing with a dictionary with mutable keys is what dictates
that keys must be immutable; enforcing this limitation is a far better
alternative than implementing a standard dictionary that must take into
account all the nasty side effects of key objects which can change
state, thereby affecting the lookup table.  (Likely it would involve
adding complexity to the _objects_ themselves, such as with notifiers
and callbacks to handle the case of changes and conflicts.)

I see the same thing happening here.  It certainly would be nice if sets
could have mutable objects as elements -- in the same way it would be
nice if dictionaries could have mutable keys -- but it is not worth the
added complexity and headache.

-- 
 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