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

Chris Angelico rosuav at gmail.com
Sun Feb 8 02:23:17 CET 2015


On Sun, Feb 8, 2015 at 12:07 PM, Ed Kellett <edk141 at gmail.com> wrote:

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.

I don't know that actually having a True value for everything would necessarily help, but in terms of defining operations like union and intersection, it should be broadly equivalent to solving the same problem with a dict/OrderedDict.

ChrisA



More information about the Python-ideas mailing list