[Numpy-discussion] Unexpected behavior with numpy array

Gael Varoquaux gael.varoquaux@normalesup....
Sun Feb 3 13:29:16 CST 2008


On Sun, Feb 03, 2008 at 12:25:56PM -0700, Damian Eads wrote:
> On similar note, does the assignment

>        A = A * B

> create a new array with a new buffer to hold the result of A * B, and 
> assign A to refer to the new array?

Yes. Without a JIT, Python cannot know that A is present both on the RHS
and on the LHS of the equation.

If you want to modify in place A, you can do

A *= B

HTH,

Gaël


More information about the Numpy-discussion mailing list