robertwb / issues-import-test

0 stars 0 forks source link

reversed(range(start, stop, step)) is wrong #774

Closed robertwb closed 12 years ago

robertwb commented 12 years ago

When iterating over reversed(range()), the reversed swaps the bounds of the range() and offsets it by one. This is wrong for a step that is not 1 or -1. Example:

cdef int i
for i in reversed(range(0, 10, 4)):
    print i

print list(reversed(range(0, 10, 4)))

output:

9
5
1
[4, 0](8,)

Migrated from http://trac.cython.org/ticket/763

robertwb commented 12 years ago

scoder changed owner from somebody to scoder I've disabled the optimised looping for this case:

https://github.com/cython/cython/commit/f766a7fc2a4b7fa67b2db8592034980bff9c5783

robertwb commented 12 years ago

scoder changed resolution to fixed status from new to closed Follow-up ticket for optimising this case is in http://cython.trac.org/ticket/765.