Fixed-width array storage
Define arrays with predictable per-element integer width for binary formats, interfaces, or memory-sensitive data.
NumPy · Type Alias
np.int32 is NumPy's fixed-width 32-bit integer type. Use it for integer scalars or as an array dtype when a 32-bit representation is required.
np.int32 is NumPy's concrete signed integer scalar type with exactly 32 bits. Use it as an array dtype, a scalar constructor, or an input to dtype- and integer-introspection APIs when fixed-width integer representation matters.
numpy.int32A NumPy 32-bit integer scalar when called as a constructor; as a dtype specifier, it selects the corresponding 32-bit integer dtype.
np.int32 combines the integer category with a 32-bit width to identify one concrete NumPy numerical type.numpy.int32 to the C integer family and describes it as a platform-defined integer type with 32 bits.np.int32 as the dtype argument when an array should contain 32-bit integers.np.int32 selects the corresponding integer dtype.np.int_ or np.intp when a fixed 32-bit width is required.import numpy as np
values = np.array([1, 2, 3], dtype=np.int32)
print(values.dtype) # int32
print(np.iinfo(np.int32).min)
print(np.iinfo(np.int32).max)Creates an array whose elements use NumPy's fixed 32-bit integer type, then displays its dtype and representable limits.
Define arrays with predictable per-element integer width for binary formats, interfaces, or memory-sensitive data.
Create NumPy integer scalars that participate in NumPy operations using the 32-bit integer dtype.
Check the representable range before converting or validating integer data.
np.int32 represent?np.int32 is a NumPy concrete integer type with 32 bits. It provides a fixed-width integer representation, unlike platform-dependent types whose widths can vary.
Follow-up: How would you inspect its limits? Use np.iinfo(np.int32), then read the returned object's min and max attributes.
np.int32 when creating an array?Pass dtype=np.int32 to array creation to request 32-bit integer storage. You can also construct a scalar with np.int32(value).
Follow-up: How can you verify the resulting array type? Inspect its .dtype attribute, which should report int32.
NumPy defines a basic numerical type by combining a category with a numeric bitsize. For np.int32, the bitsize is 32, meaning 32 bits are used for one value in memory.
Follow-up: Why not use np.int_ for the same guarantee? Its bitsize may depend on the platform, whereas np.int32 is fixed-width.
numpy.int16numpy.int64numpy.intcnumpy.int_numpy.intpnumpy.dtypenumpy.iinfo