[Python-ideas] Add orderedset as set(iterable, *, ordered=False) and similarly for frozenset.
Ed Kellett
edk141 at gmail.com
Sat Feb 7 23:22:44 CET 2015
On Fri Feb 06 2015 at 01:17:03 Nathaniel Smith <njs at pobox.com> wrote:
>
> Surely a.union(b) should produce the same result as a.update(b) except
> out-of-place, and .update() already has well-defined semantics for
> OrderedDicts.
>
I don't think they are equivalent. update() makes sense because it's
described as a procedure mutating one operand - among other implications,
it fundamentally doesn't commute. On the other hand, set union is
commutative, and changing that seems strange (and wrong) to me.
I think it'd be more sensible to add .extend() and + operations to ordered
sets if that's a useful thing to do to them. It mirrors the fact that they
are (more or less) mutable sequences, and it's more obvious what the order
of the result is (and + on sequences is already non-commutative).
In any case, I'm evidently wrong about this being a trivial decision. :)
Ed Kellett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150207/968176b6/attachment.html>
More information about the Python-ideas
mailing list