On Thu, 2013-05-23 at 15:42 +0100, Nathaniel Smith wrote: > On Thu, May 23, 2013 at 3:19 PM, Matthieu Brucher > <matthieu.bruc...@gmail.com> wrote: > > Hi, > > > > It's to be expected. You are overwritten one of your input vector while it > > is still being used. > > So not a numpy bug ;) > > Sure, that's clearly what's going on, but numpy shouldn't let you > silently shoot yourself in the foot like that. Re-using input as > output is a very common operation, and usually supported fine. > Probably we should silently make a copy of any input(s) that overlap > with the output? For high-dimensional dot, buffering temprary > subspaces would still be more memory efficient than anything users > could reasonably accomplish by hand.
Not sure whether you can easily implement buffering of subspaces with the (g)ufunc machinery, but that shouldn't worry much. The other thing is, that this problem generally exists for all ufuncs, only that for normal ones it is more difficult to trigger. This is after all much like the old, common and completely warranted complaint that `a += a.T` is not well defined. Only that for np.dot fixing it is a bit more obvious since nobody would abuse such in-place behaviour. Personally I think detecting this and at least warning for now in the (g)ufunc machinery would make a lot of sense. We can just hope someone feels like attempting such a feature :). - Sebastian > > -n > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion