Ticket #763 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

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

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

Description

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
[8, 4, 0]

Change History

Changed 2 years ago by scoder

  • owner changed from somebody to scoder

Changed 2 years ago by scoder

  • status changed from new to closed
  • resolution set to fixed

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

Note: See TracTickets for help on using tickets.