Dictionary order (Is it consistent up to py3.3 unless using -R or PYTHONHASHSEED is set)
Steve D'Aprano
steve+python at pearwood.info
Sun May 28 12:46:57 EDT 2017
On Mon, 29 May 2017 12:15 am, Jon Ribbens wrote:
> On 2017-05-28, Steve D'Aprano <steve+python at pearwood.info> wrote:
>> What exactly did you think I got wrong?
>
> 3.6 does preserve the dict order. It isn't a guarantee so may change
> in future versions, but it is what 3.6 actually does.
Did I say it didn't?
I said you can't rely on it, because it might change. The OP stated:
"... python 3.6 having the added benefit of guaranteeing insertion order
is maintained?"
and I said:
"No -- there is no such guarantee for 3.6. The only language promise is that
**kwargs keyword arguments will keep insertion order. That's all.
The Python language still reserves the right to re-order dicts at any time"
both of which is true. The *plan* is to change this for a stronger promise, but
that depends on other implementations (PyPy, Jython and IronPython especially)
agreeing that they can offer the same promise without performance penalty.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list