Re: [Numpy-discussion] Question about broadcasting vs for loop performance

2014-09-14 Thread Ryan Nelson
I think I figured out my own question. I guess that the broadcasting approach is generating a very large 2D array in memory, which takes a bit of extra time. I gathered this from reading the last example on the following site: http://wiki.scipy.org/EricsBroadcastingDoc I tried this again with a muc

[Numpy-discussion] Question about broadcasting vs for loop performance

2014-09-14 Thread Ryan Nelson
Hello all, I have a question about the performance of broadcasting versus Python for loops. I have the following sample code that approximates some simulation I'd like to do: ## Test Code ## import numpy as np def lorentz(x, pos, inten, hwhm): return inten*( hwhm**2 / ( (x - pos)**2 + hwh