Fix int [r]divmod, Add rfloordiv#1239
Merged
Merged
Conversation
| if i2.is_zero() { | ||
| Err(vm.new_zero_division_error("integer division by zero".to_string())) | ||
| } else { | ||
| let modulo = (i1 % i2 + i2) % i2; |
Contributor
There was a problem hiding this comment.
Did you have a look at div_rem ? It might be more efficient for big integers. Another option might be div_mod_floor.
Member
Author
There was a problem hiding this comment.
div_rem was the original implementation which didn't match to python. I fixed them to div_floor and div_mod_floor, thanks.
| fn rfloordiv(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { | ||
| if objtype::isinstance(&other, &vm.ctx.int_type()) { | ||
| let v1 = get_value(&other); | ||
| let (div, _) = divmod(vm, v1, &self.value)?; |
Contributor
There was a problem hiding this comment.
Did you check on div_floor? This might be faster than full divmod.
d0e8ee5 to
cde8802
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR allows
import datetimeIf anyone interested in, the workflow is captured as an example patch for sprint.
https://www.slideshare.net/YunWonJeong/pycon-kr-2019-sprint-rustpython-by-example