参考链接:http://scipy.github.io/old-wiki/pages/Tentative_NumPy_Tutorial
2 复制和视图
简单操作不复制,函数引用不复制
a = arange(12)
b=a #a,b同一数组两个名字
View和浅拷贝,创建新的数组对象,但是共享数据。特别的,列表切片返回View。
>>> c = a.view()
>>> c is a
False
>>> c.base is a # c is a view of the data owned by a
True
>>> c.flags.owndata
False
>>>
>>> c.shape = 2,6 # a's shape doesn't change
>>> a.shape
(3, 4)
>>> c[0,4] = 1234 # a's data changes
>>> a
array([[ 0, 1, 2, 3],
[1234, 5, 6, 7],
[ 8, 9, 10, 11]])
深拷贝
完全拷贝数组和数据
>>> d = a.copy() # a new array object with new data is created
>>> d is a
False
>>> d.base is a # d doesn't share anything with a
False
>>> d[0,0] = 9999
>>> a
arr