One minor thing is you should use xrange rather than range. Although it will probably only make a difference for the empty loop ;)<br><br>Otherwise, from what I can see, tests where numpy is really much worse are:<br>- 1, 2, 3, 15, 18: Not numpy but Python related: for loops are not efficient<br>
- 6, 10: Maybe numpy.roll is indeed not efficiently implemented<br>- 21: Same for this scipy function<br><br>-=- Olivier<br><br><div class="gmail_quote">2011/9/26 Keith Hughitt <span dir="ltr"><<a href="mailto:keith.hughitt@gmail.com">keith.hughitt@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="gmail_quote">Hi all,<div><br></div><div>Myself and several colleagues have recently started work on a <a href="http://www.sunpy.org/" target="_blank">Python library for solar physics</a>, in order to provide an alternative to <a href="http://www.lmsal.com/solarsoft/" target="_blank">the current mainstay for solar physics</a>, which is written in IDL.</div>


<div><br></div><div>One of the first steps we have taken is to create <a href="https://github.com/sunpy/sunpy/blob/master/benchmarks/time_test3.py" target="_blank">a Python port</a> of a popular benchmark for IDL (time_test3) which measures performance for a variety of (primarily matrix) operations. In our initial attempt, however, Python performs significantly poorer than IDL for several of the tests. I have attached a graph which shows the results for one machine: the x-axis is the test # being compared, and the y-axis is the time it took to complete the test, in milliseconds. While it is possible that this is simply due to limitations in Python/Numpy, I suspect that this is due at least in part to our lack in familiarity with NumPy and SciPy.</div>


<div><br></div><div>So my question is, does anyone see any places where we are doing things very inefficiently in Python?</div><div><br></div><div>In order to try and ensure a fair comparison between IDL and Python there are some things (e.g. the style of timing and output) which we have deliberately chosen to do a certain way. In other cases, however, it is likely that we just didn't know a better method.</div>


<div><br></div><div>Any feedback or suggestions people have would be greatly appreciated. Unfortunately, due to the proprietary nature of IDL, we cannot share the original version of time_test3, but hopefully the comments in time_test3.py will be clear enough.</div>


<div><br></div><div>Thanks!<br><font color="#888888"><font color="#888888">Keith</font></font></div></div>
<br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br>