[Python-ideas] Proposal: New syntax for OrderedDict, maybe built-in
Norman Hooper
norman at kaapstorm.com
Thu Sep 4 20:11:10 CEST 2014
Hi,
On 09/04/2014 08:00 PM, David Wilson wrote:
> On Thu, Sep 04, 2014 at 07:35:06PM +0200, Norman Hooper wrote:
>
>> I work with OrderedDict a lot, because JSON represents an OrderedDict
>> and I need to work with JSON a lot.
> ECMAScript:
>
> 4.3.3 Object
> An object is a member of the type Object. It is an unordered
> collection of properties each of which contains a primitive value,
> object, or function. A function stored in a property of an object is
> called a method.
>
> JSON:
>
> 1. Introduction
> An object is an unordered collection of zero or more name/value
> pairs, where a name is a string and a value is a string, number,
> boolean, null, object, or array.
>
You are absolutely right. And as you point out ...
> implementations
> tend to preserve order when the number of keys is small, since they may
> use a more efficient internal representation in that case, whose
> enumeration order depends on order the properties were defined in.
I am not aware of any implementations (although I'm also not aware of
all implementations) that do not preserve order.
So (a bit like natural languages) one needs to conform with how it is
used, not how it is defined, if one wants to be fully understood.
Kind regards,
Norman
More information about the Python-ideas
mailing list