4 ms·
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 th
by je42 9y ago
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.
- kllrnohj 9y agoEven 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_tables 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.
- jnwatson 9y agoIn Python 3.6, dicts are now ordered.
- je42 9y agoit's an implementation detail. not guaranteed. :( which makes this even worse.