[Numpy-discussion] minor improvment to ones
Grissiom
chaos.proton at gmail.com
Fri Jan 30 10:09:07 EST 2009
On Fri, Jan 30, 2009 at 22:16, Sturla Molden <sturla at molden.no> wrote:
> On 1/30/2009 3:07 PM, Grissiom wrote:
>
> > Is fill function has any advantage over ones(size)*x ?
>
> You avoid filling with ones, all the multiplications and creating an
> temporary array. It can be done like this:
>
> a = empty(size)
> a[:] = x
>
> Which would be slightly faster and more memory efficient.
>
>
Hmm, I +1 on this one. It's more pythonic ;)
--
Cheers,
Grissiom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090130/0f4797b1/attachment.html>
More information about the NumPy-Discussion
mailing list