Re:Hope – A Python JIT for astrophysical computations
by mborch on Friday October 17, 2014 @01:41PM
(#8472228)
Assuming this is Python 2.x (doesn't seem to be specified in the benchmark results), then the use of "range" is problematic (should be "xrange").
[ Parent
| on HN ]
Re:Hope – A Python JIT for astrophysical computations
by MrMeker on Friday October 17, 2014 @02:30PM
(#8472578)
Not really. "range" returns a list, "xrange" returns an iterator. I assume that the list is much easier to reason about in a JIT. In python3, range is a type of its own and certainly more useful for in a JIT.
https://docs.python.org/3/library/stdtypes.html#typesseq-ran...
Re:Hope – A Python JIT for astrophysical computations
by mborch on Friday October 17, 2014 @02:55PM
(#8472739)
How is allocating and populating a Python list order to do a simple for loop in a tight inner loop not problematic? Neither CPython nor PyPy can optimize that out.
As I said, this is assuming we're on Python 2.x.
Re:Hope – A Python JIT for astrophysical computations
by rguillebert on Friday October 17, 2014 @04:26PM
(#8473157)
PyPy optimizes that out, you have a thing that looks exactly like a list, but is implemented differently under the hood
Re:Hope – A Python JIT for astrophysical computations
by shoyer on Friday October 17, 2014 @02:33PM
(#8472602)
Based on the description in the docs (http://pythonhosted.org/hope/lang.html#loops), my guess is that "for i in range(N)" is directly translated into something like "for (i = 0; i < N; i++)" in the C++.