Numpy快速入门官方教程:
https://docs.scipy.org/doc/numpy-dev/user/quickstart.html
复制操作
Numpy中复制操作有三种,分别总结。
=
Simple assignments make no copy of array objects or of their data.
这是高级语言如C#等引用类型,对a的引用加1。
view
The view method creates a new array object that looks ate the same data.
这个方法只是在栈上重新分配了一个新的地址,这个地址依然指向a地址指向的堆上的空间。
这也就表明 c 改变堆上的内容,a也会改变。
help(a.view)
Help on built-in function view:
view(...) method of numpy.ndarray instance
a.view(dtype=None, type=None)
New view of array with the same data.
Parameters
----------
dtype : data-type or ndarray sub-class, optional
Data-type descriptor of the returned view, e.g., float32 or int16. The
default, None, results in the view having the same data-type as `a`.
This argument can also be specified as an ndarray sub-class, which
then specifies the type of the returned object (this is equival