David Cournapeau wrote: > Sven Schreiber wrote: > >> Yes it's intended; as far as I understand the python/numpy syntax, <+> >> is an operator, and that triggers assignment by copy (even if you do >> something trivial as bar = +foo, you get a copy, if I'm not mistaken), >> >> > So basically, whenever you have > > foo = expr > > with expr is a numpy expression containing foo, you trigger a copy ? >
I think you are better off understanding that "=" is a name binding operation while "+=" calls a special method that allows in-place adding. Thus, bar += foo calls bar.__iadd__(bar, foo) which gives the opportunity to add foo to bar in-place while bar = bar + foo adds bar to foo (which results in a new array that then gets re-bound to the name bar). The '=' sign is not an operator. Perhaps this will help you see the difference. It's good to know what kinds of things trip people up. We can target tutorials and FAQs to those things. -Travis ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion