[Python-Dev] PEP 431 Updates
Antoine Pitrou
solipsis at pitrou.net
Mon Jan 28 13:52:58 CET 2013
Le Mon, 28 Jan 2013 22:31:29 +1000,
Nick Coghlan <ncoghlan at gmail.com> a écrit :
>
> >> 6. Under "New collections"
> >>
> >> Why both lists and sets?
> >
> > Because pytz did it. But yes, you are right, an ordered set is a
> > better solution. Baseing it on OrderedDict seems like a hack,
> > though. I could implement a custom orderedset, of course.
>
> Sets themselves have an honourable history of just being a thin
> wrapper around dictionaries with all the values set to None (although
> they're not implemented that way any more). Whether you create an
> actual OrderedSet class, or just expose the result of calling keys()
> on an OrderedDict instance is just an implementation detail, though.
Why the complication? Just expose a regular set and let users call
sorted() if that's what they want.
I'm -1 on datetime shipping its own container subclass just for the
sake of looking clever.
Regards
Antoine.
More information about the Python-Dev
mailing list