您的位置:首页 > 编程语言 > Python开发

numpy中的ndarray与array的区别、不同

2017-09-14 22:02 686 查看
翻译自stackoverflow上的回答

https://stackoverflow.com/questions/15879315/what-is-the-difference-between-ndarray-and-array-in-numpy

问:What is the difference between ndarray and array in Numpy? And where can I find the implementations in the numpy source code?

(Numpy中ndarray和array的区别是什么?我在哪儿能够找到numpy中相应的实现?)

答:Well, np.array is just a convenience function to create an ndarray, it is not a class itself.

(嗯,np.array只是一个便捷的函数,用来创建一个ndarray,它本身不是一个类)

You can also create an array using np.ndarray, but it is not the recommended way. From the docstring of np.ndarray:

(你也能够用np.ndarray来创建,但这不是推荐的方式。来自np.ndarray的文档:)

Arrays should be constructed using array, zeros or empty … The parameters given here refer to a low-level method (ndarray(…)) for instantiating an array.

(Arrays 应该能用array,zeros 或empty来构造…这里的参数和一个实例化array的低层方法与有关)

Most of the meat of the implementation is in C code, here in multiarray, but you can start looking at the ndarray interfaces here:

https://github.com/numpy/numpy/blob/master/numpy/core/numeric.py
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: