[Python-ideas] Add orderedset as set(iterable, *, ordered=False) and similarly for frozenset. (original) (raw)

Ed Kellett edk141 at gmail.com
Sun Feb 8 02:07:38 CET 2015


On Sun Feb 08 2015 at 12:52:56 AM Chris Angelico <rosuav at gmail.com> wrote:

To be quite honest, I would be very happy if sets had more of the operations that dictionaries have. Imagine if "set" were "dictionary where all the values are True", and "OrderedSet" were "OrderedDict where all the values are True"; combining sets is like combining dictionaries, but you don't have to worry about merging the values.

I think they already have most of the useful ones. Adding True values seems unnecessary, to me—that entries have no value seems more appropriate in terms of merging them making sense.

ISTM ordered set addition/union should be like list concatenation with duplicates dropped.

I agree about addition - that'd mirror list concatenation nicely. But with that in mind, making union do the same thing seems wrong - partly because it'd be an exact duplicate of other functionality, and partly because it's a special case:

Ed Kellett -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150208/d139a668/attachment.html>



More information about the Python-ideas mailing list