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

Chris Angelico rosuav at gmail.com
Sun Feb 8 01:50:33 CET 2015


On Sun, Feb 8, 2015 at 11:34 AM, Neil Girdhar <mistersheik at gmail.com> wrote:
> You make a good point, but I'm still unfortunately unconvinced.  If it were
> called UniqueList, I would agree with you.  Since it's called OrderedSet, I
> expect it to use the same operations as set.

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.

ISTM ordered set addition/union should be like list concatenation with
duplicates dropped. But then, I'm not a mathematician; which, come to
think of it, is why I use "Practicality beats purity" Python rather
than one of the more mathematically-pure functional languages.

ChrisA


More information about the Python-ideas mailing list