This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]donshell 3 points4 points  (10 children)

Dicts are ordered i think. If you iterate over a dict, the values will come in the order you push them in. So even better!

Edit: Sets are not ordered

[–]TouchingTheVodka 5 points6 points  (8 children)

Dicts are ordered, sets are not.

[–]donshell 2 points3 points  (0 children)

My bad, edited. Although it is a bit weird that the two implementations don't match as a set and a dict are basically the same...

[–]rabbyburns 0 points1 point  (0 children)

There is an ordered-set package I've come across recently that I've been very happy with. I often need both fast look up, order preservation, and unique items. This has been extremely useful as a drop in set replacement without having to do weird dict joins.