
But we're not talking about *dict*, we're talking about dict.items which returns a set-like object:
py> from collections.abc import Set py> isinstance({}.items(), Set) True
So dict.items isn't subscriptable because it's an unordered set, not a sequence.
Or is it a set because it can’t be indexed? If I have the history right, dict.items was first implemented with the “old” dict implementation, which did not preserve order, but did provide O(1) access, so making the dict views set-like was easy, and making them Sequences was impossible. But now dicts do preserve order, and so making the dict views sequence-like IS possible, and can be done efficiently—so why not? But if a simple indexable dict is all you need, try writing a subclass. I don’t think it’s possible to make that efficient without access to the dict internals. -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython