numpy/numpy — pull request #3535 by arinkverma (2013-07-18 22:05:45+00:00)
Title: ENH: Added code generator logic for innerloop lookup in  generate_umath.py

Implementation
----------------------
* Reduced signature array into distinct types, now 32

E.g These sets (add, subtracts) , (arccos, arcsin, arctan, arcsinh, arccosh) share same signature array
* For each distinct signature array, auto-gen lookup function having if-else condition which check and return index

E.g

static int input1_id7_index(int x, int y){
if ( x == NPY_HALF ) { return x+(-23); }
if ( x >= NPY_FLOAT && x <= NPY_LONGDOUBLE ) { return x+(-10); }
if ( x == NPY_OBJECT ) { return x+(-13); }
return -1;
}

* Most of binary operations have input of same type, so check for homogeneous inputs first then rests like date, time etc
* Encapsulates logic, with ((PyUFuncObject *)f)->sig_index(arg1, args2)

Improvement
-------------------
PyUFunc_DefaultLegacyInnerLoopSelector doesn't appear on call-graph mostly. This save 3-4% of time used to be consumed to find proper index by searching to nargs*types array