[Python-Dev] Set data type
David Ascher
DavidA@ActiveState.com
Thu, 3 Feb 2000 16:53:03 -0800
Ka-Ping Yee, on sets:
I think you forgot one behavior:
>>> t.append('Spam!')
>>> t.append('Spam!')
KeyError: set already contains value 'Spam!'
no? FWIW, I don't like the use of the word 'append', which to me implies a
serial order. I'd use 'add', but that's a nit.
> 2. How do sets sort?
[..]
> a. The answer is the same as whatever answer we get when
> Python supports rich comparisons and instances can have
> partial orderings too.
[..]
> (Side note: Do we achieve a. just by divorcing __cmp__ from
> >, >=, etc.?
I think we hashed (pun!) all of this out a couple of years ago in one of
your hibernation periods =). I'll try to find the deja thread on the topic.
> ((Side side side note: in E, Mark Miller also ran into the
> problem of spelling different kinds of "equals"es. For
> object identity we have "is", for content comparison we
> have "==". If we need a new operator for magnitude equality
> i suggest "<=>", as used in E.))
Isn't magnitude equality currently spelled len(a) == len(b)?
> Well, it may be a lot of words, but it's not much good unless you
> are going to use it in practice. I think i would have good use for
> it, but i would like to hear your opinions. Would you use such a
> thing?
I use some of the features of such a thing now by making up dictionaries
with None as values for all the keys.
I have no strong feeling re: whether we need a new datatype for sets.
-david ascher