A python list can contain disparately typed objects, e.g. X = ['apples', 'oranges',10]. If you do type([10]) you'll see the Python type for the container is technically called a list, not an array.

In contrast, in a numpy array all objects are of the same type, the dtype.

The docs are telling you that on creation of a numpy array, the dtype is set to the type that will hold all of the existing objects.

See, look:

the type will be determined as the minimum type required to hold the objects in the sequence

The writers perhaps should have added "and not their values"

We can make a uint8 ten easily enough:

ten = np.uint8(10)

If that is put into a Python list, it retains its type because Python lists preserve types. If that list is sent to numpy.array() to make a numpy array, then the numpy array will use dtype np.uint8 because it is big enough to hold all (1) of the pre-existing Python list objects.

In [49]: np.array([ten]).dtype
Out[49]: dtype('uint8')

But if we use a literal 10, python will create an int object for it instead of an np.uint8 because np.uint8 is peculiar to numpy and all 10 does is invoke python to create that number.

If we make a Python list containing a literal 10, we duplicate your result (with machine-architecture ints):

In [50]: np.array([10]).dtype
Out[50]: dtype('int64')

And if we put the two types together in a python list, and send that list to np.array for creation of a numpy array, then the dtype must be big enough to hold both objects, in this case int64.

In [51]: np.array([ten, 10]).dtype
Out[51]: dtype('int64')
Answer from Paul on Stack Overflow
🌐
NumPy
numpy.org › doc › stable › reference › arrays.dtypes.html
Data type objects (dtype) — NumPy v2.5 Manual
32-bit integer, which is interpreted as consisting of a sub-array of shape (4,) containing 8-bit integers: ... 32-bit integer, containing fields r, g, b, a that interpret the 4 bytes in the integer as four unsigned integers: >>> dt = np.dtype(('i4', [('r','u1'),('g','u1'),('b','u1'),('a','u1')])) ... When checking for a specific data type, use == comparison. ... Try it in your browser! ... As opposed to Python types, a comparison using is should not be used.
🌐
W3Schools
w3schools.com › python › numpy › numpy_data_types.asp
NumPy Data Types
We use the array() function to create arrays, this function can take an optional argument: dtype that allows us to define the expected data type of the array elements: ... import numpy as np arr = np.array([1, 2, 3, 4], dtype='S') print(arr) ...
🌐
NumPy
numpy.org › doc › 2.3 › reference › arrays.dtypes.html
Data type objects (dtype) — NumPy v2.3 Manual
32-bit integer, which is interpreted as consisting of a sub-array of shape (4,) containing 8-bit integers: ... 32-bit integer, containing fields r, g, b, a that interpret the 4 bytes in the integer as four unsigned integers: >>> dt = np.dtype(('i4', [('r','u1'),('g','u1'),('b','u1'),('a','u1')])) ... When checking for a specific data type, use == comparison. ... Try it in your browser! ... As opposed to Python types, a comparison using is should not be used.
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.ndarray.dtype.html
numpy.ndarray.dtype — NumPy v2.2 Manual
Setting will replace the dtype without modifying the memory (see also ndarray.view and ndarray.astype). ... Cast the values contained in the array to a new data-type.
🌐
Python Course
python-course.eu › numerical-programming › numpy-data-objects-dtype.php
3. Numpy Data Objects, dtype | Numerical Programming
Before we work with a complex data structure like the one shown above, let’s first introduce dtype using a very simple example. We define a data type based on int16 and refer to it as i16. (Admittedly, this isn’t a very descriptive name, but we’ll use it just for this example.) The elements of a list named lst are then converted to the i16 type to create a two-dimensional array called A. import numpy as np i16 = np.dtype(np.int16) print(i16) lst = [ [3.4, 8.7, 9.9], [1.1, -7.8, -0.7], [4.1, 12.3, 4.8] ] A = np.array(lst, dtype=i16) print(A)
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.ndarray.dtype.html
numpy.ndarray.dtype — NumPy v2.5 Manual
January 31, 2021 - >>> import numpy as np >>> x = np.arange(4).reshape((2, 2)) >>> x array([[0, 1], [2, 3]]) >>> x.dtype dtype('int64') # may vary (OS, bitness) >>> isinstance(x.dtype, np.dtype) True
🌐
Imperial College London
python.pages.doc.ic.ac.uk › 2022 › lessons › numpy › 02-ndarray › 04-dtype.html
Introduction to NumPy and Matplotlib > np.dtype | Python Programming (70053 Autumn Term 2022/2023) | Department of Computing | Imperial College London
>>> x = np.array([0, 1, 2, 3]) >>> print(x.dtype) int64 # or int32 depending on your machine >>> x = np.array([0.0, 1.1, 2, 3]) >>> print(x.dtype) float64 >>> x = np.array(["a", "b", "c", "d"]) >>> print(x.dtype) <U1 # a unicode string · int32 refers to a 32-bit integer, while int64 refers to a 64-bit integer. Simply put, you can represent larger numbers with a larger number of bits. You can also explicitly specify the dtype in the constructor. This can either be standard Python types (e.g.
🌐
NumPy
numpy.org › doc › 2.1 › reference › arrays.dtypes.html
Data type objects (dtype) — NumPy v2.1 Manual
32-bit integer, which is interpreted as consisting of a sub-array of shape (4,) containing 8-bit integers: ... 32-bit integer, containing fields r, g, b, a that interpret the 4 bytes in the integer as four unsigned integers: >>> dt = np.dtype(('i4', [('r','u1'),('g','u1'),('b','u1'),('a','u1')])) When checking for a specific data type, use == comparison. ... As opposed to Python types, a comparison using is should not be used.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › data-type-object-dtype-numpy-python
Data type Object (dtype) in NumPy Python - GeeksforGeeks
May 20, 2026 - Explanation: attribute arr.dtype returns the data type of the array elements, which is int in this case because all values are integers. A dtype object is an instance of the numpy.dtype class.
Top answer
1 of 1
4

A python list can contain disparately typed objects, e.g. X = ['apples', 'oranges',10]. If you do type([10]) you'll see the Python type for the container is technically called a list, not an array.

In contrast, in a numpy array all objects are of the same type, the dtype.

The docs are telling you that on creation of a numpy array, the dtype is set to the type that will hold all of the existing objects.

See, look:

the type will be determined as the minimum type required to hold the objects in the sequence

The writers perhaps should have added "and not their values"

We can make a uint8 ten easily enough:

ten = np.uint8(10)

If that is put into a Python list, it retains its type because Python lists preserve types. If that list is sent to numpy.array() to make a numpy array, then the numpy array will use dtype np.uint8 because it is big enough to hold all (1) of the pre-existing Python list objects.

In [49]: np.array([ten]).dtype
Out[49]: dtype('uint8')

But if we use a literal 10, python will create an int object for it instead of an np.uint8 because np.uint8 is peculiar to numpy and all 10 does is invoke python to create that number.

If we make a Python list containing a literal 10, we duplicate your result (with machine-architecture ints):

In [50]: np.array([10]).dtype
Out[50]: dtype('int64')

And if we put the two types together in a python list, and send that list to np.array for creation of a numpy array, then the dtype must be big enough to hold both objects, in this case int64.

In [51]: np.array([ten, 10]).dtype
Out[51]: dtype('int64')
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.ndarray.dtype.html
numpy.ndarray.dtype — NumPy v2.1 Manual
Setting will replace the dtype without modifying the memory (see also ndarray.view and ndarray.astype). ... Cast the values contained in the array to a new data-type.
🌐
NumPy
numpy.org › doc › stable › user › basics.types.html
Data types — NumPy v2.5 Manual
Some dtypes have trailing underscore ... a set of fixed-size aliases are provided (See Sized aliases). NumPy generally returns elements of arrays as array scalars (a scalar with an associated dtype)....
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.ndarray.dtype.html
numpy.ndarray.dtype — NumPy v2.3 Manual
>>> import numpy as np >>> x = np.arange(4).reshape((2, 2)) >>> x array([[0, 1], [2, 3]]) >>> x.dtype dtype('int64') # may vary (OS, bitness) >>> isinstance(x.dtype, np.dtype) True
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.dtype.html
numpy.dtype — NumPy v2.5 Manual
The array-protocol typestring of this data-type object. ... Tuple (item_dtype, shape) if this dtype describes a sub-array, and None otherwise.
🌐
NumPy
numpy.org › doc › 2.2 › reference › arrays.dtypes.html
Data type objects (dtype) — NumPy v2.2 Manual
32-bit integer, which is interpreted as consisting of a sub-array of shape (4,) containing 8-bit integers: ... 32-bit integer, containing fields r, g, b, a that interpret the 4 bytes in the integer as four unsigned integers: >>> dt = np.dtype(('i4', [('r','u1'),('g','u1'),('b','u1'),('a','u1')])) When checking for a specific data type, use == comparison. ... As opposed to Python types, a comparison using is should not be used.
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: astype() to change dtype of an array | note.nkmk.me
February 4, 2024 - The non-Python type uint must be specified using the string 'uint'. a = np.array([1, 2, 3], dtype=int) print(a.dtype) # int64 a = np.array([1, 2, 3], dtype='int') print(a.dtype) # int64 ... The range of values for integer (int, uint) and floating-point number (float) can be checked with np.iinfo() and np.finfo(). Use np.iinfo() for integers (int, uint). ... Specifying a data type as an argument returns a numpy.iinfo object, which can be inspected using print() to see an overview, or its max and min attributes can be accessed to obtain the maximum and minimum values as numbers.
🌐
DataCamp
datacamp.com › doc › numpy › data-types
NumPy Data Types
In this syntax, `dtype=np.int32` specifies that the array elements should be stored as 32-bit integers. python import numpy as np array = np.array([1, 2, 3], dtype=np.int32) print(array.dtype)
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.dtype.html
numpy.dtype — NumPy v2.1 Manual
The array-protocol typestring of this data-type object. ... Tuple (item_dtype, shape) if this dtype describes a sub-array, and None otherwise.
🌐
Programiz
programiz.com › python-programming › numpy › datatypes
NumPy Data Types (With Examples)
Here, we have created types of ... numbers whose default data type is complex128 · In NumPy, we can create an array with a defined data type by passing the dtype parameter while calling the np.array() function....