A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-March/117282.html below:

[Python-Dev] slice subscripts for sequences and mappings

[Python-Dev] slice subscripts for sequences and mappings [Python-Dev] slice subscripts for sequences and mappingsEli Bendersky eliben at gmail.com
Sat Mar 3 13:41:24 CET 2012
>> I'd expect slice subscripts to be part of the sequence interface, and
>> yet they are not. In fact, they are part of the mapping interface. For
>> example, the list object has its slice get/set methods assigned to a
>> PyMappingMethods struct. So does a bytes object, and pretty much every
>> other object that wants to support subscripts.
>
> It comes from:
> http://hg.python.org/cpython/rev/245224d1b8c9
> http://bugs.python.org/issue400998
>
> Written by Michael Hudson and reviewed by Guido.
> I wonder why this patch chose to add mapping protocol support to tuples
> and lists, rather than add a tp_ slot for extended slicing.
>

Why a separate tp_ slot for extended slicing? ISTM slicing pertains to
sequences, similarly to other numeric indices. If you look at
PySequenceMethods it has these (apparently no longer used fields):

    void *was_sq_slice;
    void *was_sq_ass_slice;

These were "simple" slices (pairs of numbers). I suppose if any change
is considered, these fields can be re-incarnated to accept PyObject*
slices similarly to the current mp_subscript and mp_ass_subscript.

Eli
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4