On Tue, Jun 30, 2020 at 09:33:25PM -0700, Christopher Barker wrote:
I wasn't justifying it -- I was simply saying that no one ever specifically decided that we DIDN'T want to be able to index dict views -- when they were created, it simply wasn't an option. Now it is, so we need to rethink it.
Of course it was an option. Dicts always had *some* internal order, it is just that this internal order was an artifact of how the hash table was built, the history of insertions and deletions, etc. Keys appeared in some arbitrary order, not "no order at all".
So there has always been the option to return the nth item according to that arbitrary order. It would be (presumably) the same order as items would appear if you iterated over the dict, or printed it.
The only difference now is that instead of having keys appear is some arbitrary order, we can guarantee they appear in a non-arbitrary order.
Under what circumstances would you find it useful to access the fifth key or item added to the dict?
Having a consistant, predictable, deterministic order is useful. Having that deterministic order be insertion order is useful. Associating an explicit index to the items, I'm not so sure.
Even if the performance were bad, I don't think we'd be handing out a foot gun here: who's going to write:
when they know what the key is for the nth item?
Who is going to write it at all? This still strikes me as a feature in search of a use-case.