(no title)
jonathaneunice | 2 months ago
This is optimizing for the common case, where memory is generally plentiful and dicts grow more than they shrink. Python has so many memory inefficiencies that occasional tombstones in the dict internal structure is unlikely to be a major effect. If you're really concerned, do `d = dict(d)` after aggressive deletion.
zahlman|2 months ago
I can't say I've noticed any good reasons to rely on it. Didn't reach for `OrderedDict` often back in the day either. I've had more use for actual sorting than for preserving the insertion order.
BiteCode_dev|2 months ago
This morning for example, I tested an object serialized through a JSON API. My test data seems to never match the next run.
After a while, I realized one of the objects was using a set of objects, which in the API was turned into a JSON array, but the order of said array would change depending of the initial Python VM state.
3 days ago, I used itertools.group by to group a bunch of things. But itertools.group by only works on iterable that are sorted by the grouping key.
Now granted, none of those recent example are related to dicts, but dict is not a special case. And it's iterated over regularly.
mcherm|2 months ago
xen0|2 months ago
I don't often care about a specific order, only that I get the same order every time.
morshu9001|2 months ago
vanviegen|2 months ago
kzrdude|2 months ago
For me, it creates more reproducible programs and scripts, even simple ones.
seanhunter|2 months ago
I would expect to use a different data structure if I needed an ordered set.
LtWorf|2 months ago