[Numpy-discussion] Quick Question about Optimization
Mon May 19 15:04:46 CDT 2008
On Mon, May 19, 2008 at 12:53 PM, Robin <firstname.lastname@example.org> wrote:
> I think my understanding is somehow incomplete... It's not clear to me
> why (simplified case)
> a[curidx,:] = scalar * a[2-curidx,:]
> should be faster than
> a = scalar * b
> In both cases I thought the scalar multiplication results in a new
> array (new memory allocated) and then the difference between copying
> that result into the existing array u[curix,:] or reassining the
> reference u to that result should be very similar?
> If anything I would have thought the direct assignment would be
> quicker since then there is no copying.
> What am I missing?
Actually, I think you are correct. My bad. I was mainly thinking in
terms of weave.blitz, where it would make a difference, then
UBC Department of Computer Science
More information about the Numpy-discussion