[Numpy-discussion] A little help please?

Travis E. Oliphant oliphant@enthought....
Wed Feb 27 08:50:57 CST 2008

Neal Becker wrote:
> Travis E. Oliphant wrote:
> The code for this is a bit hard to understand.  It does appear that it only
> searches for a conversion on the 2nd argument.  I don't think that's
> desirable behavior.
> What I'm wondering is, this works fine for builtin types.  What is different
> in the handling of builtin types?

There are quite a few differences which lead to the current issues. 

1) For built-in types there is a coercion order that can be searched 
more intelligently which does not exist for user-defined
2) For built-in types all the 1d loops are stored in a single C-array in 
the same order as the signatures.  The entire signature list is scanned 
until a signature to which all inputs can be cast is found.  
3) For user-defined types the 1d loops (functions) for a particular 
user-defined type are stored in a linked-list that itself is stored in a 
Python dictionary (as a C-object) attached to the ufunc and keyed by the 
user-defined type (of the first argument).

Thus, what is missing is code to search all the linked lists in all the 
entries of all the user-defined types on input (only the linked-list 
keyed by the first user-defined type is searched at the moment).    This 
would allow similar behavior to the built-in types (but a bit more 
expensive searching).

-Travis O.

More information about the Numpy-discussion mailing list