[Numpy-discussion] Re: Speed up function on cross product of two sets?

Peter Verveer verveer at embl-heidelberg.de
Mon Apr 3 12:00:04 CDT 2006

On 3 Apr 2006, at 19:17, Robert Kern wrote:

> Zachary Pincus wrote:
>>> If I were going to make a list it would look something like:
>>> 0. Think about your algorithm.
>>> 1. Vectorize your inner loop.
>>> 2. Eliminate temporaries
>>> 3. Ask for help
>>> 4. Recode in C.
>>> 5 Accept that your code will never be fast.
>>> Step zero should probably be repeated after every other step ;)
>> Thanks for this list -- it's a good one.
>> Since we're discussing this, could I ask about the best way to
>> eliminate temporaries? If you're using ufuncs, is there some way to
>> make them work in-place? Or is the lowest-hanging fruit (temporary-
>> wise) typically elsewhere?
> Many binary ufuncs take an optional third argument which is an  
> array which the
> ufunc should put the result in.

I wished many times that all functions would support an optional  
output argument. It is not only important for speed optimization, but  
also if you work with large data sets. I guess the use of a return  
values is much more natural but when the point comes that you want to  
optimize your algorithm, the ability to use an output argument  
instead is very valuable. It would be nice if all functions by  
default would support a standard keyword argument 'output', just like  
ufuncs do. I suppose these could in principle be added while still  
maintaining backwards compatibility.

Cheers, Peter

More information about the Numpy-discussion mailing list