On Thu, 30 Jul 2020 at 23:42, Steven D'Aprano firstname.lastname@example.org wrote:
Of course anything is possible in theory, but I think that would require shifting the existing keys and values in the array, and updating the entries in the hash table to point to their key in the new position, and probably other complications I haven't thought of.
Also list must shift the internal array. You don't have to update the hashtable. For example, when you pop an item, the key is not removed from the hashtable completely, but it's marked as dummy.
I think the main problem here is set, since set is not ordered. In theory, dict views could be an "ordered" set, so you can do:
d.keys() d.values()[1:] d.items() = "omg"
In any case, if people want to propose turning dicts into fully-fledged
reorderable, slicable sequences as well as mappings, they will probably need a PEP :-)
I'm just brainstorming. Not sure about the real use-case.