numpy/numpy — pull request #3505 by arinkverma (2013-07-05 15:46:14+00:00)
Title: ENH: added check for scalar array in get_ufunc_arguments from umath/ufunc_object.c

In function get_ufunc_arguments, check if PyObject is of zero dimension and scalar. Then avoid heavy calls like PyArray_FromAny, hence passing obj to out_op PyArrayObject unchanged.

Call-graph comparing cumulative time
==
![scalar_array](https://f.cloud.github.com/assets/1556486/754439/a8321630-e588-11e2-9eaa-0fa98efcc5b9.jpg)

timeit
==

Before

In [1]: import numpy as np;x = np.asarray(5.5)
In [2]: timeit x*x
100000 loops, best of 3: 2.59 us per loop

After

In [1]: import numpy as np;x = np.asarray(5.5)
In [2]: timeit x*x
100000 loops, best of 3: 2.07 us per loop