This is a long-shot, but my question is to simply optimize this particular function in some code I have written:
import numpy as np
from numpy.core.umath_tests import inner1d
npgauss = np.random.standard_normal
pt = abs(np.random.standard_normal(psetLen))
pt = pt/np.sqrt(inner1d(pt,pt))
d = dict(zip(pList,pt))
dim is some integer \$n\$,
pList is simply a list of \$2^n-1\$ strings, and
psetLen is \$2^n-1\$. This function is designed to return a dictionary keyed by elements of
pList with values determined by a point on the unit \$n\$-hypersphere.
At this point, I need to run this function around a billion times or so to get the results I want, which will take hours. I've done as much optimization as possible here, and my micro-optimization seems to indicate that all three major parts of the function (the random number, the normalization, and the dictionary association) all take approximately a third of the run-time, and I'm not sure how to reduce it further. I've squeezed a bit out of Cythoning it, but I'm not sure how much of an improvement that will give me as compared to actually writing it in C and then importing the C function. Unfortunately, I don't know C (or C++) and haven't written Java in years, so I'm pretty stuck using Python (or extensions thereof).
Is it possible to optimize this further by any significant factor? Would changing languages help dramatically? What improvements could be made in Python?