Speed Of Np.empty Vs Np.zeros
I am using numpy version 1.14.3 and python 2.7.12. Referencing this question, I am finding dramatically different speeds between initializing arrays with np.zeros and np.empty. Ho
Solution 1:
np.empty
and np.zeros
do different things.
np.empty
creates an array from available memory space, leaving whatever values happened to be hanging around in memory as the values. These values may or may not be zeros.
np.zeros
creates an array from available memory space, and then fills it with zeros for your chosen dtype. Obviously np.zeros
has to do more work so it should be slower, since it's also writing to the memory allocated.
A more fair comparison would be between np.empty
and np.ndarray
.
Post a Comment for "Speed Of Np.empty Vs Np.zeros"