|
From: Alexander B. <ale...@gm...> - 2006-02-21 14:51:31
|
On 2/21/06, Mads Ipsen <mp...@os...> wrote: > I suggest that rint() is added as a ufunc or is there any concerns > here that I am not aware of? You might want to use astype(int). On my system it is much faster than aro= und: > python -m timeit -s "from numpy import array, around; x =3D array([1.5]*1= 000)" "around(x)" 10000 loops, best of 3: 176 usec per loop > python -m timeit -s "from numpy import array, around; x =3D array([1.5]*1= 000)" "x.astype(int)" 100000 loops, best of 3: 3.2 usec per loop the difference is too big to be explained by the fact that around allocates twice as much memory for the result. In fact the following equivalent of rint is still very fast: > python -m timeit -s "from numpy import array, around; x =3D array([1.5]*1= 000)" "x.astype(int).astype(float)" 100000 loops, best of 3: 6.48 usec per loop |