On Wed, Mar 16, 2011 at 8:58 AM, Paul Anton Letnes < paul.anton.let...@gmail.com> wrote:
> > On 16. mars 2011, at 15.49, Chris Barker wrote: > > > On 3/16/11 6:34 AM, Charles R Harris wrote: > >> On Wed, Mar 16, 2011 at 7:24 AM, Paul Anton Letnes > > > >> Yes, it is intentional. Numpy is more C than Python in this case, > > > > I don't know that C has anything to do with it -- the *= operators were > > added specifically to be "in-place" operators -- otherwise they would be > > nothing but syntactic sugar. And IIRC, numpy was one of the motivators. > > > > IMHO, the mistake was even allowing += and friends for immutables, as > > that inherently means something different. > > > > Of course, using += with integers is probably the most common case. > > > > -Chris > > I see. In that case, I have the following either/or christmas wish: > > Either: implement a warning along the following lines: > >>> from numpy import * > >>> a = zeros(10, dtype=complex) > >>> a.astype(float) > /Users/paulanto/Library/Python/2.7/bin/bpython:2: ComplexWarning: Casting > complex values to real discards the imaginary part > # EASY-INSTALL-ENTRY-SCRIPT: > 'bpython==0.9.7.1','console_scripts','bpython' > array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) > > This comes up for discussion on a fairly regular basis. I tend towards the more warnings side myself, but you aren't going to get the current behavior changed unless you can convince a large bunch of people that it is the right thing to do, which won't be easy. For one thing, a lot of current code in the wild would begin to raise warnings that weren't there before. Or: give me a hint how and where to change the numpy code, and I could try > to write a patch. > > You have to go down to the C level to deal with this. Chuck
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion