What is the difference between ndarray and array in NumPy?
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
In NumPy discussions, array and ndarray are often used as if they mean the same thing. They are related, but not identical. ndarray is the actual NumPy array type, while np.array(...) is one of the factory functions that creates an ndarray from other data.
ndarray Is the Core NumPy Data Type
ndarray stands for N-dimensional array. It is the class that stores the array's shape, data type, memory layout, and values.
When you run this code, type(values) is numpy.ndarray. That is the key point: the thing you manipulate in NumPy is usually an ndarray instance.
ndarray supports vectorized operations, broadcasting, slicing, reshaping, and many of the features that make NumPy fast.
np.array(...) Is a Constructor Function
When people say "a NumPy array," they often mean an object created by np.array(...).
Here, np.array(...) is a function that takes list-like input and returns an ndarray. It is similar to how list(...) creates a Python list or dict(...) creates a dictionary.
That means the difference is mostly one of role:
- '
ndarrayis the class' - '
np.array(...)is a common way to create an instance of that class'
The Name array Can Also Mean Other Things
The confusion gets worse because Python also has an array module in the standard library.
These are different types with different goals. The standard-library array.array is a compact one-dimensional container. NumPy's ndarray supports multidimensional data and numerical operations that the standard library type does not.
So when someone writes "array," context matters. They might mean the generic idea of an array, the np.array(...) constructor, the resulting ndarray, or even array.array from the standard library.
np.array(...) Versus np.asarray(...)
A practical distinction that matters more in real code is between np.array(...) and np.asarray(...).
np.array(...) may copy data unless you tell it not to. np.asarray(...) tries to avoid copying when the input is already an ndarray with a suitable dtype.
This matters for performance, memory use, and whether modifications affect the original object.
Why ndarray Matters More Than the Constructor
Most NumPy behavior lives on the ndarray object itself. Attributes such as shape, strides, dtype, and methods such as reshape, sum, and astype belong to the array instance.
Once the object exists, the fact that it was originally created by np.array(...) is usually no longer important. What matters is that it is an ndarray.
Use the Right Mental Model
A clean mental model is:
- NumPy's main array object is
numpy.ndarray - '
np.array(...)is a convenience function that usually creates one' - the word "array" in conversation is often informal shorthand
This model helps when reading documentation, debugging types, and understanding performance behavior. For example, a function that expects an ndarray may still accept any array-like input because NumPy can convert it internally.
Common Pitfalls
- Thinking
arrayandndarrayare two competing NumPy container types. - Forgetting that
np.array(...)is a constructor function, not the underlying type name. - Mixing up NumPy arrays with
array.arrayfrom Python's standard library. - Assuming
np.array(...)never copies data. - Using the word "array" too loosely when type details matter.
Summary
- '
ndarrayis NumPy's actual N-dimensional array class.' - '
np.array(...)is a function that commonly creates anndarray.' - In casual discussion, people often use "array" as shorthand for a NumPy
ndarray. - Python's standard-library
array.arrayis a different type. - For performance-sensitive code, it is useful to understand how
np.array(...)differs fromnp.asarray(...).
Related reading
- What is the difference between normalisation and regularisation in machine learning
- What is the difference between np.array and np.asarray?
- What is the difference between np.mean and tf.reduce_mean?
- What is the difference between np.mean and tf.reduce_mean?
- What is the difference between Python's list methods append and extend?
- What is the difference between Set and List?
- What is the difference between null=True and blank=True in Django?
- What is the difference between nullTrue and blankTrue in Django?

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.