Given a NumPy array of int32
, how do I convert it to float32
in place? So basically, I would like to do
a = a.astype(numpy.float32)
without copying the array. It is big.
The reason for doing this is that I have two algorithms for the computation of a
. One of them returns an array of int32
, the other returns an array of float32
(and this is inherent to the two different algorithms). All further computations assume that a
is an array of float32
.
Currently I do the conversion in a C function called via ctypes
. Is there a way to do this in Python?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…