Why does numpy.array behave differently than Python's list and default arrays when it comes to slicing? Please consider the examples below:
1) using lists: the statement b = a[1:3] creates a new list object, and modifying b does not modify a.
>>> a = [1,2,3,4]
>>> b = a[1:3]
>>> print(b)
[2, 3]
>>> b[0] = -17
>>> print(b)
[-17, 3]
>>> print(a)
[1, 2, 3, 4]
2) using array.array: the statement b = a[1:3] once again creates a new array object, and modifying b does not modify a.
>>> import array
>>> a = array.array('i', [1,2,3,4])
>>> b = a[1:3]
>>> print(b)
array('i', [2, 3])
>>> b[0] = -17
>>> print(b)
array('i', [-17, 3])
>>> print(a)
array('i', [1, 2, 3, 4])
3) using numpy.array: the statement b = a[1:3] seems to reference the values of the original list, and modifying it does modify a as well!
>>> import numpy
>>> a = numpy.array([1,2,3,4])
>>> b = a[1:3]
>>> print(b)
[2 3]
>>> b[0] = -17
>>> print(b)
[-17 3]
>>> print(a)
[ 1 -17 3 4]
The question is: why is this behaviour present in numpy?