PEP 218 Re: ANN: set-0.1 module available

Fernando Pérez fperez528 at yahoo.com
Fri May 17 18:29:12 EDT 2002


James J. Besemer wrote:

> Actually Denis seemed to be suggesting that sets themselves should be
> immutable so they could Serve as dictionary keys.  I think it's very
> plausable that sets would be used in this manner..

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.

I guess if you want to insist on sets being usable as keys you might come up 
with a pair of set-like types just like we have lists/tuples. But if sets are 
ever going to be part of the language, _please_ don't make them immutable. In 
my mind, that's like saying that you add integers to a language but you can't 
do arithmetic with them ;)

Cheers,

f.




More information about the Python-list mailing list