Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

actually, you should see the pain that you get when having unordered dictionaries by default.

which is the default in python, you get awesome effects, where the order of the unordered dictionary is dependent on the random seed.

where library implementor are serializing a dict into a serial structure (and are not sorting by key). running the same code and same data twice, will get you potentially different results.

now here comes the best. most of the time in python you don't see the difference. the output is exactly the same but never the less the order is not guaranteed.

so I believe having an ordered by default data-store will help the ecosystem.

Calling it unordered explicitly helps, to make sure that anybody serializing the structure will need to make a choice how to sort it.



Even if you want ordered by default a red-black tree is a bad way to get it. JavaScript has ordered maps, but engines like V8 use things like this: https://wiki.mozilla.org/User:Jorend/Deterministic_hash_tabl... instead.

It's not a question of ordered vs. unordered, it's a question of red-black trees vs. a hashed array of some sort.


In Python 3.6, dicts are now ordered.


it's an implementation detail. not guaranteed. :( which makes this even worse.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: