Opened 4 years ago

Closed 4 years ago

#763 closed defect (fixed)

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

Reported by: mark Owned by: scoder
Priority: blocker Milestone: 0.16
Component: Code Generation Keywords:


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)))


[8, 4, 0]

Change History (2)

comment:1 Changed 4 years ago by scoder

  • Owner changed from somebody to scoder

comment:2 Changed 4 years ago by scoder

  • Resolution set to fixed
  • Status changed from new to closed

Follow-up ticket for optimising this case is in #765.

Note: See TracTickets for help on using tickets.