[Python-ideas] Deprecating the old-style sequence protocol

Serhiy Storchaka storchaka at gmail.com
Sun Dec 27 02:30:45 EST 2015


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.




More information about the Python-ideas mailing list