[Numpy-discussion] Inplace index suprise
James Philbin
philbinj@gmail....
Thu Mar 20 14:43:41 CDT 2008
Hi,
> More importantly, it is technically impossible because of the way that
> *Python* works. See the thread "Histograms via indirect index arrays"
> for a detailed explanation.
>
> http://projects.scipy.org/pipermail/numpy-discussion/2006-March/006877.html
OK, that makes things much clearer. You say this is technically
impossible, but I think there is a (albeit messy) way of doing this.
If A[I] were to return a proxy object instead of an array (overloading
the requisite methods so that operations on the proxy affect A via one
level of indirection), then the methods can be written to do the right
thing. This would have the added advantage of eliminating a copy. This
is BTW how a lot of the clever tricks (especially for sparse matrices)
are done in the boost::ublas matrix library. I'm not saying anyone
should actually do this, but it does seem to be technically
*possible*.
Thanks,
James
More information about the Numpy-discussion
mailing list