From: A. M. A. <per...@gm...> - 2006-10-08 23:08:31
|
On 08/10/06, Robert Kern <rob...@gm...> wrote: > Bill Baxter wrote: > > Yes, that'd be > > a[b] += c > > No, I'm afraid that fancy indexing does not do the loop that you are thinking it > would (and for reasons that we've discussed previously on this list, *can't* do > that loop). That statement reduces to something like the following: So the question remains, is there a for-loop-free way to do this? (This, specifically, is: for i in range(len(b)): a[b[i]]+=c[i] where b[i] may contain repetitions.) I didn't find one, but came to the conclusion that for loops are not necessarily slower than fancy indexing, so the way to do this one is just to use a for loop. A. M. Archibald |