[Python-Dev] Guarantee ordered dict literals in v3.7? (original) (raw)
Steve Dower steve.dower at python.org
Sun Nov 5 18:32:58 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 ]
Since there is voting going on, -1 on changing the guarantees of dict
. If ordering is important, OrderedDict is more explicit and more obvious to the over reading the code, even if the underlying implementation is identical.
Good luck teaching people about why Python went from OrderedDict to UnorderedDict within a version. I remember learning about this same thing in C++ and just thinking “wut?”. And they just added a new type and said to stop using the old one – not changing something that people already understand.
Better to underspecify the default dict and offer explicitly named extensions (DefaultDict, OrderedDict, etc.) for those who want more guarantees.
Cheers, Steve
Top-posted from my Windows phone
From: Peter Ludemann via Python-Dev Sent: Sunday, November 5, 2017 12:53 To: Sven R. Kunze Cc: Python-Dev Subject: Re: [Python-Dev] Guarantee ordered dict literals in v3.7?
Isn't ordered dict also useful for **kwargs?
If it turns out that there's a dict implementation that's faster by not preserving order, collections.UnorderedDict could be added. There could also be specialized implementations that pre-size the dict (cf: C++ unordered_map::reserve), etc., etc. But these are all future things, which might not be necessary.
On 5 November 2017 at 12:44, Sven R. Kunze <srkunze at mail.de> wrote: +1 from me too.
On 04.11.2017 21:55, Jim Baker wrote: +1, as Guido correctly recalls, this language guarantee will work well with Jython when we get to the point of implementing 3.7+.
On Sat, Nov 4, 2017 at 12:35 PM, Guido van Rossum <guido at python.org> wrote: This sounds reasonable -- I think when we introduced this in 3.6 we were worried that other implementations (e.g. Jython) would have a problem with this, but AFAIK they've reported back that they can do this just fine. So let's just document this as a language guarantee.
On Sat, Nov 4, 2017 at 10:30 AM, Stefan Krah <stefan at bytereef.org> wrote:
Hello,
would it be possible to guarantee that dict literals are ordered in v3.7?
The issue is well-known and the workarounds are tedious, example:
https://mail.python.org/pipermail/python-ideas/2015-December/037423.html
If the feature is guaranteed now, people can rely on it around v3.9.
Stefan Krah
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (python.org/~guido)
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/jbaker%40zyasoft.com
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/srkunze%40mail.de
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/pludemann%40google.com
-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20171105/a0aa3be0/attachment.html>
- 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 ]