[Numpy-discussion] numarraycore

Todd Miller jmiller at stsci.edu
Wed May 5 13:52:03 CDT 2004

On Wed, 2004-05-05 at 16:27, Colin J. Williams wrote:
> It would help to have some documentation on the purpose and usage of the 
> class UsesOpPriority and its variable op_priority.

The basic idea was that NumArray subclasses which want to use numarray
operators would:

1.  subclass from UsesOpPriority 

2.  set a class level op_priority > 0. 

NumArrays have op_priority 0,  higher priorities are given "precedence".

Thus, given A=NumArray(...) and B=NumArraySubclass(...), and
A.op_priority==0 and B.op_priority==1, then:  
A+B would execute as B.__radd__(A) rather than A.__add__(B) and hence
the type(A+B) could be NumArraySubclass rather than NumArray.  Different
subclasses could use higher or lower op_priorities to perform the same
kind of operator resolution among themselves.

Todd Miller <jmiller at stsci.edu>

More information about the Numpy-discussion mailing list