[Python-Dev] Guarantee ordered dict literals in v3.7? (original) (raw)
Barry Warsaw barry at python.org
Mon Nov 6 14:33:10 EST 2017
- Previous message (by thread): [Python-Dev] Guarantee ordered dict literals in v3.7?
- Next message (by thread): [Python-Dev] Guarantee ordered dict literals in v3.7?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Nov 6, 2017, at 11:23, Paul G <paul at ganssle.io> wrote:
Is there a major objection to just adding in explicit syntax for order-preserving dictionaries?
I don’t think new syntax is necessary. We already have OrderedDict, which to me is a perfectly sensible way to spell “I need a mapping that preserves insertion order”, and the extra import doesn’t bother me.
I’m not saying whether or not to make the language guarantee that built-in dict preserves order. I’m just saying that if we don’t make that language change, we already have everything we need to support both use cases.
If we did make the change, it’s possible we would need a way to explicit say that order is not preserved. That seems a little weird to me, but I suppose it could be useful. I like the idea previously brought up that iteration order be deliberately randomized in that case, but we’d still need a good way to spell that.
Cheers, -Barry
-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: Message signed with OpenPGP URL: <http://mail.python.org/pipermail/python-dev/attachments/20171106/491f8d0a/attachment.sig>
- Previous message (by thread): [Python-Dev] Guarantee ordered dict literals in v3.7?
- Next message (by thread): [Python-Dev] Guarantee ordered dict literals in v3.7?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]