[Python-Dev] PEP 431 Updates
Lennart Regebro
regebro at gmail.com
Tue Jan 29 00:28:55 CET 2013
On Mon, Jan 28, 2013 at 11:17 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On 28/01/13 23:52, Antoine Pitrou wrote:
>>
>> 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.
>
>
> An OrderedSet is not a sorted set.
>
> An OrderedSet, like an OrderedDict, remembers *insertion order*, it does
> not automatically sort the keys. So if datetime needs an ordered set, and
> I have no opinion on whether or not it really does, calling sorted() on a
> regular set is not the solution.
I think the use case for needing really quick checks if a string is in
the list of recognized timezone is rather unusual. What is usually
needed is a sorted list of valid time zone names. I'll drop the set.
//Lennart
More information about the Python-Dev
mailing list