As of 3.7, dict objects are guaranteed to maintain insertion order. But set objects make no such guarantee, and AFAIK in practice they don't maintain insertion order either. Should they?
I do have a use case for this. In one project I maintain a "ready" list of jobs; I need to iterate over it, but I also want fast lookup because I soemtimes remove jobs when they're subsequently marked "not ready". The existing set object would work fine here, except that it doesn't maintain insertion order. That means multiple runs of the program with the same inputs may result in running jobs in different orders, and this instability makes debugging more difficult. I've therefore switched from a set to a dict with all keys mapped to None, which provides all the set-like functionality I need.
ISTM that all the reasons why dicts should maintain insertion
order also apply to sets, and so I think we should probably do
this. Your thoughts?
/arry
p.s. My dim recollection is that the original set object was a
hacked-up copy of the dict object removing the ability to store
values. So there's some precedent for dicts and sets behaving
similarly. (Note: non-pejorative use of "hacked-up" here, that
was a fine way to start.)