numpy/numpy — pull request #4174 by juliantaylor (2014-01-05 19:46:03+00:00)
Title: ENH: speed up ufunc reduce argument parsing

PyArg_ParseTupleAndKeywords makes out about 20% of the runtime of small
reductions. Replace it with faster parsing using pre-interned python
strings. This improves performance by about 15% for reductions in the
order of 100 elements.
Error handling is done by calling PyArg_ParseTupleAndKeywords after the
fast parsing fails.

before:

d = np.arange(100)
%timeit np.sum(d)
100000 loops, best of 3: 4.79 µs per loop

after:

d = np.arange(100)
%timeit np.sum(d)
100000 loops, best of 3: 4.03 µs per loop