27 Dec
2015
27 Dec
'15
7:30 a.m.
On 27.12.15 08:22, Nick Coghlan wrote:
These days, without considering the presence or absence of any non-dunder methods, the core distinction between sequences, multi-dimensional arrays and arbitrary mappings really lies in the type signature of the key parameter to__getitem__ et al (assuming a suitably defined Index type hint):
MappingKey = Any DictKey = collections.abc.Hashable SequenceKey = Union[Index, slice] ArrayKey = Union[SequenceKey, Tuple["ArrayKey", ...]]
ArrayKey also includes Ellipsis.