On Dienstag 25 März 2008, Nadav Horesh wrote: > scalars are immutable objects in python. Thus the += (and alike) are "fake":
Again, thanks for the explanation. IMHO, whether or not they are fake is an implementation detail. You shouldn't have to know Python's guts to be able to use Numpy successfully. Even if they weren't fake, implementing my suggested semantics in Numpy wouldn't be particularly hard. > [snip] > a += 3 is really equivalent to a = a+3. Except when it isn't. > [snip] > numpy convention is consistent > with the python's spirit. A matter of taste. > I really use that fact to write arr1 += > something, in order to be sure that the type of arr1 is conserved, and > write arr1 = arr1+something, to allow upward type casting. I'm not trying to make the operation itself go away. I'm trying to make the syntax beginner-safe. Complete loss of precision without warning is not a meaning that I, as a toolkit designer, would assign to an innocent-looking inplace operation. My hunch is that many people who start with Numpy will spend an hour of their lives hunting a spurious bug caused by this. I have. Think of the time we can save humanity. :) Andreas
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
