<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 7, 2015 at 6:02 PM, Ed Kellett <span dir="ltr"><<a href="mailto:edk141@gmail.com" target="_blank">edk141@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><span class="">On Sat Feb 07 2015 at 10:37:39 PM Chris Angelico <<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Set union is, but sets lack order. Once you add order to a set, it<br>
becomes more like a list</blockquote><div><br></div></span><div>Then wouldn't adding .extend() and + make more sense anyway? List-like operations should look like the list-like operations we already have.</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">so the union of x and y might not be <span style="font-size:13.1999998092651px">identical to the union of y and x</span></blockquote><div><br></div></span><div>Well, not if you define union to be non-commutative, no—but that's what we're discussing.</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span style="font-size:13.1999998092651px">They'd be the same modulo order, so </span><span style="font-size:13.1999998092651px">it's not breaking the concept of set union.</span></blockquote><div><br></div></span><div>Sure it is: operations are supposed to yield things that make sense. Set union yields the set of elements contained in any of its operands; even if its operands have orderings that make sense, the ordering between sets might be partial or inconsistent, so the result cannot. So the existing definition of set union can never produce a correct ordering.</div><div><br></div><div>I can't see why it would be preferable to redefine union as concatenation rather than just supporting explicit concatenation. Apart from feeling more mathematically sound to me, it's better at documenting intention: which method (or operator) you choose reflects whether you're interested in the order of the result or just its contents.</div></div></div></blockquote><div><br></div><div>The reason is that that's already what update does, which is the most common way to use OrderedSet.  Typically, you have a bunch of things and you want a set of unique elements in the order they were added.  So you create your accumulator and then update it with iterables of elements, after which it contains your desired ordered set of unique elements.  Maybe your code looks like this:</div><div><br></div><div>a = OrderedSet() </div><div><br></div><div>a.update(b)</div><div><br></div><div>a.update(c)</div><div><br></div><div>a.update(d)</div><div><br></div><div>Why shouldn't that be the same as</div><div><br></div><div>a | b | c | d</div><div><br></div><div>?</div><div><br></div><div>I think it should and that in general union should be equivalent in effect to copy and extend.</div><div><br></div><div>Best,</div><div><br></div><div>Neil</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><span class="HOEnZb"><font color="#888888"><div><br></div><div>Ed Kellett</div></font></span></div></div><div class="HOEnZb"><div class="h5">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.<br>
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/python-ideas/4WZbMC2pNe0/unsubscribe" target="_blank">https://groups.google.com/d/topic/python-ideas/4WZbMC2pNe0/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href="mailto:python-ideas+unsubscribe@googlegroups.com" target="_blank">python-ideas+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank">https://groups.google.com/d/optout</a>.<br>
</div></div><br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br>
<br>
--<br>
<br>
---<br>
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.<br>
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/python-ideas/4WZbMC2pNe0/unsubscribe" target="_blank">https://groups.google.com/d/topic/python-ideas/4WZbMC2pNe0/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href="mailto:python-ideas%2Bunsubscribe@googlegroups.com">python-ideas+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank">https://groups.google.com/d/optout</a>.<br>
<br></blockquote></div><br></div></div>