[Matrix-SIG] Feature of numeric slicing?
James Boyle
boyle@pcmdi.llnl.gov
Tue, 24 Mar 1998 09:32:33 -0800 (PST)
In playing with some slicing of Numeric
arrays I found the following:
(Python 1.5, the latest Numeric release 1.1?)
>>>a = Numeric.arrayrange(0,5)
>>>a
>>>array[0,1,2,3,4]
>>>c = a[1:3]
>>>c
>>>array[1,2]
>>>c[0] = 99
>>>a
>>>array[0, 99, 2, 3, 4]
>>>c
>>>array[99,2]
Is this a desired property, a feature or a bug? I have not seen
it documented, but I could have easily missed it.
It appears that c just points to a section of the array a.
If an operation such as c = a[1:3]*2.0 is carried out then
c is a new object but a plain slice retains a connection of
slicer and slicee.
In Python it is my understanding that a slice creates a new object, without
references to the slicee.
Any words of wisdom?
Jim Boyle