On 2017-05-28, Bill Deegan <b...@baddogconsulting.com> wrote: > As a follow up to a discussion on IRC #python channel today. > > Assuming the same order of insertions of the same items to a dictionary > would the iteration of a dictionary be the same (not as the order of > insertion, just from run to run) for Python 2.7 up to python 3.3? And again > at Python 3.6? > (Also for py 3.3 through 3.5.x if PYTHONHASHSEED=0) > > With python 3.6 having the added benefit of guaranteeing insertion order is > maintained?
I think Steve missed the point of what you were asking, as well as being wrong about dict order in 3.6. Here's the official line on that: The order-preserving aspect of this new implementation is considered an implementation detail and should not be relied upon (this may change in the future, but it is desired to have this new dict implementation in the language for a few releases before changing the language spec to mandate order-preserving semantics for all current and future Python implementations ( https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-compactdict ) If you're asking "given a fixed Python version, and where appropriate PYTHONHASHSEED=0, will dictionaries created the same way always iterate in the same order" then that seems pretty much true by definition (how could it not be true?), as well as being an explicit guarantee in Python 3.3-3.5. ( https://docs.python.org/3.3/using/cmdline.html#envvar-PYTHONHASHSEED ) -- https://mail.python.org/mailman/listinfo/python-list