What is the difference between ndarray and array in numpy?

前端 未结 5 1736
一个人的身影
一个人的身影 2020-11-28 01:27

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

5条回答
  •  再見小時候
    2020-11-28 01:49

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

    You can also create an array using numpy.ndarray, but it is not the recommended way. From the docstring of numpy.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.

    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

提交回复
热议问题