numpy/numpy — pull request #3509 by arinkverma (2013-07-06 13:24:09+00:00)
Title: ENH: added short path scalar array in get_ufunc_arguments from ufunc_object.c

In function get_ufunc_arguments, check if object is of array dimension zero, then avoid heavy calls like PyArray_FromAny. Hence passing obj to out_op PyArrayObject unchanged.

Also PyArray_FromAny(obj,NULL,0,0,0,NULL) calls PyArray_FromArray(obj,NULL,0) which return original obj

Call-graph comparing cumulative time
==
Following is the callgraph of

import timeit
timeit.timeit('x+x',number=20000000,setup='import numpy as np;x = np.asarray(1.0);')

![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.01 us per loop