Re: Slicing with negative strides

2013-11-06 Thread Peter Cacioppi
On Monday, October 28, 2013 10:22:00 PM UTC-7, Steven D'Aprano wrote:
 Does anyone here use slices (or range/xrange) with negative strides other 
 
 than -1?
 

Non default positive strides are very handy, but negative strides seem weird to 
me. Not the negative striding exactly, but the way fenceposts and negative 
strides interact.

For example, this poster seems to posit a canonical WTF with negative strides. 

http://stackoverflow.com/questions/5798136/python-reverse-stride-slicing

I can almost picture Picard saying WTF do you need to omit the end index to 
get the zero element??!!

Readability counts, no? Just reverse it and use positive strides. 





-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Slicing with negative strides

2013-11-04 Thread Steven D'Aprano
On Mon, 04 Nov 2013 00:15:40 +0100, Martin Manns wrote:

 On 29 Oct 2013 05:22:00 GMT
 Steven D'Aprano st...@pearwood.info wrote:
 
 Does anyone here use slices (or range/xrange) with negative strides
 other than -1?
 
 I have used negative strides for comparing discrete sequences e. g. for
 turbulence analysis, and I hope that my code will still run in Python 4.

Can you show us a typical example of how you would normally use such 
negative strides?


Thanks,



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Slicing with negative strides

2013-11-03 Thread Martin Manns
On 29 Oct 2013 05:22:00 GMT
Steven D'Aprano st...@pearwood.info wrote:

 Does anyone here use slices (or range/xrange) with negative strides
 other than -1?

I have used negative strides for comparing discrete sequences e. g. for
turbulence analysis, and I hope that my code will still run in Python 4.

Martin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Slicing with negative strides

2013-10-29 Thread Duncan Booth
Steven D'Aprano st...@pearwood.info wrote:

 Does anyone here use slices (or range/xrange) with negative strides
 other than -1?
 
 E.g. sequence[2:15:-3]

With any negative stride your example is just the empty sequence.

 
 
 If so, there is a discussion (long, long, looong discussion) on
 the python-ideas mailing list, debating whether or not to deprecate or
 change the behaviour of slicing with negative strides. So if you care
 about the current behaviour, now is the time to stand up and be
 counted. 
 
 (Standing up *here* is fine, don't feel that you have to join yet
 another list.)
 
For those of us that don't really want to join another mailing list, could 
you summarise what change is being proposed?


-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Slicing with negative strides

2013-10-29 Thread Mark Lawrence

On 29/10/2013 05:22, Steven D'Aprano wrote:

Does anyone here use slices (or range/xrange) with negative strides other
than -1?

E.g. sequence[2:15:-3]



In 10 ish years I don't recall ever considering it, let alone doing it.

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: Slicing with negative strides

2013-10-29 Thread Mark Lawrence

On 29/10/2013 08:53, Duncan Booth wrote:

Steven D'Aprano st...@pearwood.info wrote:


Does anyone here use slices (or range/xrange) with negative strides
other than -1?

E.g. sequence[2:15:-3]


With any negative stride your example is just the empty sequence.




If so, there is a discussion (long, long, looong discussion) on
the python-ideas mailing list, debating whether or not to deprecate or
change the behaviour of slicing with negative strides. So if you care
about the current behaviour, now is the time to stand up and be
counted.

(Standing up *here* is fine, don't feel that you have to join yet
another list.)


For those of us that don't really want to join another mailing list, could
you summarise what change is being proposed?



Umpteen options have been put forward.  IMHO the bookies favourite is 
currently being endorsed by Tim Peters and Terry Reedy, yours odds may 
vary :)


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: Slicing with negative strides

2013-10-29 Thread Terry Reedy

On 10/29/2013 4:53 AM, Duncan Booth wrote:

Steven D'Aprano st...@pearwood.info wrote:


Does anyone here use slices (or range/xrange) with negative strides
other than -1?

E.g. sequence[2:15:-3]


With any negative stride your example is just the empty sequence.


The idea is that one would not have to reverse 2 and 15 to get a 
non-empty sequence.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Slicing with negative strides

2013-10-29 Thread Steven D'Aprano
On Tue, 29 Oct 2013 08:53:08 +, Duncan Booth wrote:

 Steven D'Aprano st...@pearwood.info wrote:
 
 Does anyone here use slices (or range/xrange) with negative strides
 other than -1?
 
 E.g. sequence[2:15:-3]
 
 With any negative stride your example is just the empty sequence.

Gah, sorry about that, that's the suggested *new* syntax. Possibly my 
subconscious likes it better than my conscious :-)

Try this instead: sequence[15:2:-3]


 If so, there is a discussion (long, long, looong discussion) on the
 python-ideas mailing list, debating whether or not to deprecate or
 change the behaviour of slicing with negative strides. So if you care
 about the current behaviour, now is the time to stand up and be
 counted.
 
 (Standing up *here* is fine, don't feel that you have to join yet
 another list.)
 
 For those of us that don't really want to join another mailing list,
 could you summarise what change is being proposed?

* Negative strides should be deprecated and then removed.

* Or just deprecated.

* Or change the semantics of negative strides so that 
  seq[2:15:-2] works as expected.

* Or get rid of negative indexing.

* Or add new syntax to control whether or not the end points are included.

* Or ... 


It's Python-Ideas, otherwise known as Bike-Shed Central :-)

I think the main idea which is likely (since Guido seems to be slightly 
leaning that way) is to deprecate negative strides, remove them in a 
release or three, and then re-introduce them in Python 4000 but with more 
intuitive semantics.



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Slicing with negative strides

2013-10-28 Thread Steven D'Aprano
Does anyone here use slices (or range/xrange) with negative strides other 
than -1?

E.g. sequence[2:15:-3]


If so, there is a discussion (long, long, looong discussion) on the 
python-ideas mailing list, debating whether or not to deprecate or change 
the behaviour of slicing with negative strides. So if you care about the 
current behaviour, now is the time to stand up and be counted.

(Standing up *here* is fine, don't feel that you have to join yet another 
list.)



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list