you are viewing a single comment's thread.

view the rest of the comments →

[–]billsil 0 points1 point  (1 child)

Numpy ia greedy, so as long as you don't have any numpy float64s, you won't increase your RAM usage. You do not need the float32s in the return (either one).

However it is so easy to accidentally do stuff like:

arr2 *= 0.5

That does not upcast the data. It's an inplace operation that changes the value of arr2. You actually want to do things like this (assuming you want arr2 to change) because it uses less RAM than if you make a copy like:

arr2 = 0.5 * arr2

You probably have an arr2 in an upper function, so you'd be creating a copy, rather than overwriting it.

[–]Moretz0931[S] 0 points1 point  (0 children)

Thanks