[Python-Dev] slice subscripts for sequences and mappings

Stefan Behnel stefan_ml at behnel.de
Sat Mar 3 22:12:27 CET 2012


Thomas Wouters, 03.03.2012 21:59:
> Why even have separate tp_as_sequence and tp_as_mapping anymore? That
> particular distinction never existed for Python types, so why should it
> exist for C types at all? I forget if there was ever a real point to it,
> but all it seems to do now is create confusion, what with many sequence
> types implementing both, and PyMapping_Check() and PySequence_Check() doing
> seemingly random things to come up with somewhat sensible answers. Do note
> that the dict type actually implements tp_as_sequence (in order to support
> containtment tests) and that PySequence_Check() has to explicitly return 0
> for dicts -- which means that it will give the "wrong" answer for another
> type that behaves exactly like dicts.
> 
> Getting rid of the misleading distinction seems like a much better idea
> than trying to re-conflate some of the issues.

We're too far away from the release of Python 4 to change something with
that kind of impact, though.

Stefan



More information about the Python-Dev mailing list