Ordered dict by default
Steve Holden
steve at holdenweb.com
Thu Feb 5 13:48:57 EST 2009
bearophileHUGS at lycos.com wrote:
> Bryan Olson:
>> A few bits fuzzy. Is the following True or False if dict is insert-ordered?
>> dict(a=6, b=7) == dict(b=7, a=6)
>
> In my odict implementation I have disallowed that syntax because if
> you want to define a mydict(**kwds) function that allows a syntax
> like:
>
> mydict(a=6, b=7)
>
> it takes a dict as argument, such dict is currently not ordered. If
> built-in dicts become ordered, then that dict too may become
> ordered :-)
>
> Anyway, maybe it's good to ignore the inserting order of items when
> you look for odict equality.
>
But then they wouldn't be equal. As I said right at the start if this
thread:
> one of the prime issues every time
> this comes up is the inability of the various proponents to agree on how
> dicts should actually be ordered.
The remainder of the thread vindicates that comment.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list