Typed list
This lesson is a brief introduction to Typed list and how it is implemented using the NumPy library.
We'll cover the following
Introduction
One of the strengths of NumPy is that it can be used to build new objects or to
subclass the ndarray object. This
later process is a bit tedious but it is worth the effort because it allows you
to improve the ndarray
object to suit your problem.
We’ll examine in the following section two real-world cases (typed list and memory-aware array) that are extensively used in the glumpy project (that I maintain).
What is a Typed list?
Typed list (also known as ragged array) is a list of items that all have the same data type (in the sense of NumPy). They offer both the list and the ndarray
API (with some restriction of course) but because their respective APIs may not be compatible in some cases, we have to make choices. For example, concerning the +
operator, we’ll choose to use the NumPy API where the value is added to each individual item instead of expanding the list by appending a new item (1).
Get hands-on with 1400+ tech skills courses.