As Carcigenicate pointed out, you can use array.array directly as a type annotation. However, you can't use array.array[int] or array.array[float] to specify the type of the elements.

If you need to do this, my suggestion is to use MutableSequence from collections.abc, since arrays implement all of the necessary operations: __len__, __getitem__, __setitem__, __contains__, __iter__, etc.

from collections.abc import MutableSequence

arr: MutableSequence[float] = array.array('f')
Answer from Andrew Eckart on Stack Overflow
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ array.html
array โ€” Efficient arrays of numeric values
This module defines an object type which can compactly represent an array of basic values: characters, integers, floating-point numbers. Arrays are mutable sequence types and behave very much like lists, except that the type of objects stored ...
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_arrays.asp
Python Arrays
Note: Python does not have built-in support for Arrays, but Python Lists can be used instead.
People also ask

How do I create an array in Python?
To create an array, you import the array module and use array.array(), passing a type code and list of values. This is called creating arrays in Python.
๐ŸŒ
wscubetech.com
wscubetech.com โ€บ resources โ€บ python โ€บ arrays
Arrays in Python: Types, Syntax & Examples
How to declare an array in Python?
You can use the array module to declare an array in Python. Once you import the module (import array as arr), you can declare an integer array using the following syntax: a = arr.array('i', [1,2,3])
๐ŸŒ
wscubetech.com
wscubetech.com โ€บ resources โ€บ python โ€บ arrays
Arrays in Python: Types, Syntax & Examples
What's the difference between a list and an array in Python?
Arrays hold one data type and are more efficient for math, while lists can store mixed types. If youโ€™re dealing with only numbers, arrays are better for memory and speed.
๐ŸŒ
wscubetech.com
wscubetech.com โ€บ resources โ€บ python โ€บ arrays
Arrays in Python: Types, Syntax & Examples
๐ŸŒ
CodingNomads
codingnomads.com โ€บ python-array-with-type
Python Array with Type
The array module, and specifically using array.array(), provides a quick way to create and manipulate arrays in Python. ... This creates an array of integers (type code 'i') with five elements, all initialized to 0.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-arrays
Python Arrays - GeeksforGeeks
1 week ago - In Python, array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. Unlike Python lists (can store elements of mixed types), arrays must have all elements of same type.
Find elsewhere
๐ŸŒ
WsCube Tech
wscubetech.com โ€บ resources โ€บ python โ€บ arrays
Arrays in Python: Types, Syntax & Examples
October 1, 2025 - Learn about Python arrays, their types, methods, uses, and practical examples in this tutorial. Master array manipulation and enhance your coding skills!
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ user โ€บ basics.types.html
Data types โ€” NumPy v2.4 Manual
Some dtypes have trailing underscore to avoid confusion with builtin python type names, such as numpy.bool_. Since many of these have platform-dependent definitions, a set of fixed-size aliases are provided (See Sized aliases). NumPy generally returns elements of arrays as array scalars (a ...
๐ŸŒ
Reddit
reddit.com โ€บ r/bigdata โ€บ can you have multiple data types in one array in python?
r/bigdata on Reddit: Can you have multiple data types in one array in Python?
October 3, 2022 -

The arrays in python cannot contain multiple types of data values because consecutive memory locations are initialized to hold data of the same type in the array's backend. The arrays in python cannot contain multiple types of data values because consecutive memory locations are initialized to hold data of the same type in the array's backend.

๐ŸŒ
Linode
linode.com โ€บ docs โ€บ guides โ€บ python-arrays
Python Arrays: What They Are and How to Use Them | Linode Docs
June 17, 2022 - In Python, an array is an ordered collection of objects, all of the same type. These characteristics give arrays two main benefits. First, items in an array can be consistently identified by their index, or location, within the array.
๐ŸŒ
Medium
medium.com โ€บ data-science-collective โ€บ do-more-with-numpy-array-type-hints-annotate-validate-shape-dtype-09f81c496746
Do More with NumPy Array Type Hints: Annotate & Validate Shape & Dtype | by Christopher Ariza | Data Science Collective | Medium
May 26, 2025 - It might be a one-dimensional (1D) array of Booleans, or a three-dimensional (3D) array of 8-bit unsigned integers. As the built-in function isinstance() will show, every array is an instance of np.ndarray, regardless of shape or the type of elements stored in the array, i.e., the dtype.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-create-an-array-with-a-defined-data-type-in-python
How to create an array with a defined data type in Python
Line 11: We use the array.typecode function to check the data type of the array we created. ... Line 2: We import the array module in Python.
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ arrays
Python Arrays: Syntax, Usage, and Examples
To create an array in Python, you can use either the built-in list type or the array module.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how to static type check an array of class object?
r/learnpython on Reddit: How to Static Type Check an array of Class Object?
June 10, 2021 -

Say I have a class Book: somewhere and I have a function that takes in an array of Book objects as an argument. How do I Static Type check this?
I've tried

def find_max_author(book_objects: object[ ]):

๐ŸŒ
Python Data Science Handbook
jakevdp.github.io โ€บ PythonDataScienceHandbook โ€บ 02.01-understanding-data-types.html
Understanding Data Types in Python | Python Data Science Handbook
The difference between a dynamic-type list and a fixed-type (NumPy-style) array is illustrated in the following figure: At the implementation level, the array essentially contains a single pointer to one contiguous block of data. The Python list, on the other hand, contains a pointer to a block of pointers, each of which in turn points to a full Python object like the Python integer we saw earlier.
๐ŸŒ
Internshala
trainings.internshala.com โ€บ home โ€บ programming โ€บ python โ€บ what is python arrays?
Python Array: Types , Uses, Differences, & More
March 12, 2024 - Python Array allows us to store multiple elements of the same data type in an orderly collection. These can be any valid Python variable types, such as integers, strings, booleans, and more.
๐ŸŒ
Real Python
realpython.com โ€บ python-array
Python's Array: Working With Numeric Data Efficiently โ€“ Real Python
December 22, 2023 - Thatโ€™s because the array is a specific data structure representing the list abstract data type. The list ADT dictates what operations the array must support and which behaviors it should exhibit. If youโ€™ve worked with the Python list, then you should already have a pretty good idea of what the list in computer science is all about.
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-arrays
Python Arrays: How to Create & Print Arrays using NumPy | DataCamp
August 8, 2024 - Unlike languages such as C or Java, Python does not have a built-in array data type in the traditional sense.
๐ŸŒ
Studytonight
studytonight.com โ€บ python-howtos โ€บ how-to-declare-an-array-in-python
How to declare an array in Python - Studytonight
However, Python provides a array module to declare a set of data that acts as as an array. ... In the above syntax, typecode is used to set the codes that are used to define the type of value the array will hold.