This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients skrah, terry.reedy, vstinner
Date 2014-06-27.20:46:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1403901987.45.0.497176710775.issue21856@psf.upfronthosting.co.za>
In-reply-to
Content
Memoryview should definitely have the same slice tests as other sequence objects. Go ahead and check.

I believe slice clamping itself should now be done by slice.indices, not by each class.

    S.indices(len) -> (start, stop, stride)
    
    Assuming a sequence of length len, calculate the start and stop
    indices, and the stride length of the extended slice described by
    S. Out of bounds indices are clipped in a manner consistent with the
    handling of normal slices.

It seems like this was written before it was normal for every slice to have a step (stride), defaulting to None/1. It definitely comes from 2.x, before __getslice__ was folded into __getitem__

I expect builtin 3.x sequence objects should all use something like the C equivalent of
    def __getitem__(self, ob):
        if type(ob) is slice:
           start, stop, stride = ob.indices(self.len)
           ...
History
Date User Action Args
2014-06-27 20:46:27terry.reedysetrecipients: + terry.reedy, vstinner, skrah
2014-06-27 20:46:27terry.reedysetmessageid: <1403901987.45.0.497176710775.issue21856@psf.upfronthosting.co.za>
2014-06-27 20:46:27terry.reedylinkissue21856 messages
2014-06-27 20:46:27terry.reedycreate