[Numpy-discussion] Numpy and PEP 343

Tim Hochberg tim.hochberg at cox.net
Fri Mar 3 13:41:05 CST 2006


Tim Hochberg wrote:

>>
> If there really are only a few functions, we could give them their own 
> opcodes. That means binary function still fit in 4 characters without 
> a problem.  That is:
>
> OP_ATAN2 R0, R1, R2
>
> would compute:
>   R0[:] = arctan2(R1, R2)
>
> Trinary could be defined as using their input as one of the arguments. 
> This would sometimes require an extra copy and some cleverness in the 
> compiler, but I think it would be reasonable. Thus
>
> OP_WHICH R0, R1, R2
>
> would compute:
>   R0[:] = which(R0, R1, R2)
>
> since the first argument of 'which' is often thrown away anyway, for 
> instance 'which (a < 1, b, c)', the extra copy could often be avoided 
> if we're smart. This might be a bad idea if there turns out to be 
> several more trinary functions that I'm not thinking of or if there 
> are quaternary functions we want to support. (I can't think of any 
> though).
>
Then again, it might be better to just do a simple, general solution to 
this case and pass in the arguments in an array as you say. The above 
might be pointless overengineering.

-tim






More information about the Numpy-discussion mailing list