can this be made faster?

Charles R Harris charlesr.harris at gmail.com
Mon Oct 9 13:57:43 CDT 2006


On 10/9/06, A. M. Archibald <peridot.faceted at gmail.com> wrote:
>
> On 09/10/06, Robert Kern <robert.kern at gmail.com> wrote:
> > Daniel Mahler wrote:
> > > In my case all a, b, c are large with b and c being orders of
> > > magnitude lareger than a.
> > > b is known to contain only, but potentially any, a-indexes,  reapeated
> > > many times.
> > > c contains arbitray floats.
> > > essentially it is to compute class totals
> > > as in total[class[i]] += value[i]
> >
> > In that case, a slight modification to Greg's suggestion will probably
> be fastest:
>
> If a is even moderately large and you don't care what's left behind in
> b and c you will probably accelerate the process by sorting b and c
> together (for cache coherency in a)
>
> This seems like a rather common operation - I know I've needed it on
> at least two occasions - is it worth creating some sort of C
> implementation? What is the appropriate generalization?


Some sort of indirect addressing infrastructure. But it looks like this
could be tricky to make safe, it would need to do bounds checking at the
least and would probably work best with a contiguous array as the target. I
could see some sort of low-level function called argassign(target, indirect
index, source) that could be used to build more complicated things in
python.

Chuck

A. M. Archibald
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061009/d7f2a94f/attachment.html 
-------------- next part --------------
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
-------------- next part --------------
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


More information about the Numpy-discussion mailing list