nac3core: fix len on range with step of different sign #129
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#129
Loading…
Reference in New Issue
No description provided.
Delete Branch "len_range_fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Previously I did not consider clearly about all the cases when the step is negative. In this PR I updated the formula to be, which I think should be fine..
previously the formula is just
((abs(diff) - 1) // abs(step)) + 1
You don't have to guess. Just adapt the cpython implementation:
https://github.com/python/cpython/blob/main/Objects/rangeobject.c#L182
And RustPython certainly has one as well. Maybe you could even get the LLVM IR out of rustc and essentially copy it.
Thanks a lot for the information! I implemented again using this now.
@ychenfo please do not use PR branches for unrelated commits like
1541188722