|
From: Sasha <nd...@ma...> - 2006-01-20 03:52:29
|
On 1/19/06, Mark Heslep <ma...@mi...> wrote: > A >10x hit. Am I using the preferred / optimal NumPy method here? I > scanned the earlier Scalar posts but thought that was boolean type > only issue. Try a.fill(7). On my system: > python -m timeit -s "import numpy as na; a =3D na.zeros((1000,1000))" "a= [:,:] =3D 7" 100 loops, best of 3: 17.1 msec per loop > python -m timeit -s "import numpy as na; a =3D na.zeros((1000,1000))" "a= .fill(7)" 100 loops, best of 3: 6.28 msec per loop You can also use empty instead of zeros, but that wont affect the timings that you presented. -- sasha |