r/programming • • Jun 27 '18

Python 3.7.0 released

https://www.python.org/downloads/release/python-370/
2.0k Upvotes

383 comments sorted by

View all comments

11

u/linuxtinkerer Jun 28 '18

Looks nice. Data classes are a good addition, so now you won't have to muck around with __slots__. I don't really get the rationale for preserving insertion order in dictionaries though.

10

u/weeeeezy Jun 28 '18

I’ve had several use cases where insertion order in dictionaries mattered for me. I resorted to using OrderedDict collection but then I lost all the benefits of defaultdict.

13

u/linuxtinkerer Jun 28 '18

I understand that there are still use cases for OrderDict, but I think it's dumb to make an implementation detail a part of the language specification.

9

u/BossOfTheGame Jun 28 '18

Definitely not, ordering dicts by default gives at least two major advantages: (1) consistency in the iteration of items across all platforms and (2) consistency in the string representation of dictionaries. I have a feeling this change will silently cut down on a lot of headaches (at least until someone goes to run 3.7 code in an earlier version).

-1

u/bigdeddu Jun 28 '18

the data structure hashmap does not guarantee ordering. It is confusing to depart from it. It will imho cause headaches to ppl parsing json and expecting order where's none.
And someone will expect assert({1:1,2:2}=={2:2,1:1}) to fail.

→ More replies (1)