numpy中的ndarray和array有什么区别? [英] What is the difference between ndarray and array in numpy?

查看:28
本文介绍了numpy中的ndarray和array有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Numpy 中的 ndarrayarray 有什么区别?我在哪里可以找到 numpy 源代码中的实现?

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

推荐答案

numpy.array 只是一个创建 ndarray 的便捷函数;它本身不是一个类.

numpy.array is just a convenience function to create an ndarray; it is not a class itself.

您也可以使用 numpy.ndarray 创建数组,但这不是推荐的方法.来自 numpy.ndarray 的文档字符串:

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

数组应该使用 arrayzerosempty 来构造......这里给出的参数是指用于实例化数组的低级方法 (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.

实现的大部分内容都在 C 代码中,这里是 multiarray,但你可以在这里开始查看 ndarray 接口:

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

这篇关于numpy中的ndarray和array有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆