On Mon, 12 Sep 2016 at 16:52 Tim Delaney <timothy.c.dela...@gmail.com>
wrote:

> On 10 September 2016 at 03:17, Guido van Rossum <gu...@python.org> wrote:
>
>> I've been asked about this. Here's my opinion on the letter of the law in
>> 3.6:
>>
>> - keyword args are ordered
>> - the namespace passed to a metaclass is ordered by definition order
>> - ditto for the class __dict__
>>
>> A compliant implementation may ensure the above three requirements
>> either by making all dicts ordered, or by providing a custom dict
>> subclass (e.g. OrderedDict) in those three cases.
>>
>
> I'd like to add one more documented constraint - that dict literals
> maintain definition order (so long as the dict is not further modified).
> This allows defining a dict literal and then passing it as **kwargs.
>

That would require all dictionaries keep their insertion order which we are
explicitly not doing (at least yet). If you look at the PEPs that are
asking for definition order they specify an "ordered mapping", not a dict.
Making dict literals do this means dict literals become "order mapping
literals" which isn't what they are; they are dict literals. I don't think
we should extend this guarantee to literals any more than any other
dictionary.


>
> Hmm - again, there's no mention of dict literals in the PEPs. I'm assuming
> that dict literals will preserve their definition order with the new
> implementation, but is that a valid assumption? Guess I can test it now
> 3.6.0b1 is out.
>

They will as an implementation detail, not because the language spec
requires it.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to