O'Reilly logo

Mastering Numerical Computing with NumPy by Mert Cuhadaroglu, Umit Mert Cakmak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How does NumPy manage memory?

Once you initialize a NumPy array, its metadata and data are stored at allocated memory locations in Random Access Memory (RAM).

import numpy as nparray_x = np.array([100.12, 120.23, 130.91])

First, Python is a dynamically typed languages; there is no need for the explicit declaration of variables types such as int or double. Variable types are inferred and you'd expect that in this case the data type of array_x is np.float64:

print(array_x.dtype)float64

The advantage of using the numpy library rather than Python is that numpy supports many different numerical data types such as bool_, int_, intc, intp, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float_, float16, float32, float64, complex_, complex64 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required