zimmerst / i2py

Automatically exported from code.google.com/p/i2py
GNU General Public License v2.0
3 stars 6 forks source link

for loop should use xrange #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The following patch to the trunk does the following:
- use xrange instead of arange (faster iterator)
- write the starting value only if necessary
- python's end value is IDL's end value + 1 (not + incval)
- when the end value ends with '-1', such as in 'for i = 0, v-1', translate it 
into 'for i in xrange(v)'

Original issue reported on code.google.com by pierre.c...@gmail.com on 21 Jan 2013 at 4:44

Attachments:

GoogleCodeExporter commented 9 years ago
In fact, the end value depends on the incval sign.
This new patch correctly translate loops with negative strides.

Original comment by pierre.c...@gmail.com on 21 Jan 2013 at 5:05

Attachments: