Suppose I have an array A of dtype int32, and I want to cast it into float64.
The standard way to do this (that I know) is A.astype('float64').
But this allocates a new array for the result. If I run this command repeatedly (with different arrays of the same shape), each time using the result and discarding it shortly after, then the overhead from these allocations can be non-negligible.
Suppose I pre-allocated an array B, with the same shape of A and of type float64. Is there a way to use the memory of B for the result of the casting, instead of allocating new memory each time?
ufuncs and numpy.dot have an 'out' argument for this, but astpye does not.
B[...] = A? --