[Python-ideas] Where did we go wrong with negative stride?
Tim Peters
tim.peters at gmail.com
Mon Oct 28 22:55:09 CET 2013
[Tim\
>> All strides start the same way, by (conceptually) selecting s[i:j]
>> first. Then the stride is applied to that contiguous slice, starting
>> with the first element and taking every abs(k) element thereafter.
>> Finally, if k is negative, that sequence is reversed. k=1, k=-1, k=2,
>> k=-2, ..., all the same.
[Terry]
> I think this is wrong. Conceptually reverse first, if indicated by negative
> stride, then select: see my previous post for my rationale, and below.
I already replied to your previous post, and agreed with you :-)
> ... I think that [::k] should continue to work
> as it does. I believe Guido only suggested deprecating negative strides with
> non-default endpoints, which implies negative strides *with* default
> endpoints should continue as are. We should not break more than necessary.
Take "yes" for an answer ;-)
>> ...
>> Did you notice that Guido titled this thread "Where did we go wrong
>> with negative stride?".;-)
> I did,
And did you notice that I posed that question to someone else? ;-)
> and I explained exactly where I thing we went wrong, which was to
> make the interpretation of i and j depend on the sign of k. Undoing this
> does not mandate B instead of A.
Agreed.
More information about the Python-ideas
mailing list