numpy/numpy — pull request #4186 by juliantaylor (2014-01-11 01:19:23+00:00)
Title: Improve small reduction performance

* intern the constant strings, was accidentally not done in the original PR.
* avoid a `__numpy_ufunc__` string attribute lookup on pure python types which are very expensive
* don't use keyword arguments for the reduction wrappers `np.sum` etc. Non keyword arguments parse a lot faster with the regular python function. This is an alternative to #4174 which improves keyword parsing in general but has higher complexity. The keyword arguments one of the major reasons `np.sum` is so much slower than `np.add.reduce` (4us vs 2.5 us).

The last point fails a `__numpy_ufunc__` test which I think is a bug in the logic of the override.
The override assumes all non input and output arguments are passed in via keyword arguments and then uses the ufunc number of inputs to consider all following arguments as output.
The last commit breaks both assumptions, `out` is not provided via a keyword and the reduction only has one input and not two as the non reduction types.
The effect is that you get a tuple `[axis, out, keepdims]` as the out argument of the ufunc.

This looks to me like a bug, but I'm not very familiar with the override, please advise.