Python Forum
Python 3.6 dict key iteration order
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3.6 dict key iteration order
#2
Note that it's not sorted, but order-preserving. These are two different things. Also it is considered implementation details and should not be relied upon. So the iteration is "correct".
Quote: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; this also helps preserve backwards-compatibility with older versions of the language where random iteration order is still in effect, e.g. Python 3.5).

All that said are you certain you are using 3.6?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Python 3.6 dict key iteration order - by buran - May-21-2018, 03:37 PM
RE: Python 3.6 dict key iteration order - by buran - May-21-2018, 08:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Understand order of magnitude performance gap between python and C++ ThelannOryat 4 2,814 Mar-17-2021, 03:39 PM
Last Post: ThelannOryat
  String index out of bounds ( Python : Dict ) kommu 2 2,494 Jun-25-2020, 08:52 PM
Last Post: menator01
  Python 2 to 3 dict sorting joshuaprocious 2 71,894 May-14-2020, 03:28 PM
Last Post: joshuaprocious
  Sort a dict in dict cherry_cherry 4 93,829 Apr-08-2020, 12:25 PM
Last Post: perfringo
  Python list - group by dict key karthidec 2 9,575 Nov-25-2019, 06:58 AM
Last Post: buran
  Python Turtle and order of implementation query Parsleigh 2 2,847 Mar-04-2019, 02:43 PM
Last Post: Parsleigh
  python result problem of an iteration algorithm for power allocation Jessica 1 2,753 Sep-07-2018, 08:08 PM
Last Post: micseydel
  Python Iteration Understanding giteepag 3 2,825 Jul-26-2018, 02:23 PM
Last Post: perfringo
  Python 2.7 Addition to dict is too slow VolanD 6 4,227 May-04-2018, 09:24 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020