On Sun, 29 Sep 2019 at 08:28, Kyle Stanley <aeros167@gmail.com> wrote:
Raymond also brought up a strong point to consider in https://bugs.python.org/issue25988:
The OP has a sense that Mapping and Sequence are "too heavy" but I think the reality that useful classes almost never use __getitem__ in isolation; rather, it is part of a small constellation of methods that are typically used together.
That's the point that I would make as well. What can you do with an object that is only known to be Subscriptable? With a Mapping I know that `keys` or `__iter__` give me the subscripts that can be used with it. With a Sequence `__len__` tells me the valid subscripts. Either of those makes it possible for me to build a sensible algorithm using subscripts. Without either of those what can I do in practice in a situation like this: def do_subscriptable_things(obj): if isinstance(obj, Subscriptable): # Now what? -- Oscar