-
Notifications
You must be signed in to change notification settings - Fork 1.3k
add other bytes method #847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
move trait IsByte to ByteOr refactor center refactor count fix center with negative value add test for count(integer)
Codecov Report
@@ Coverage Diff @@
## master #847 +/- ##
==========================================
+ Coverage 62.89% 64.21% +1.31%
==========================================
Files 88 88
Lines 14547 15172 +625
Branches 3288 3405 +117
==========================================
+ Hits 9150 9743 +593
+ Misses 3238 3178 -60
- Partials 2159 2251 +92
Continue to review full report at Codecov.
|
I have : split and rsplit, expandstab , partition/reparition, spitlines, zfill, replace |
I think maybe save that for another PR, yes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work. This is a very big PR so I have not yet finished going over all the code.
I am having hard time with the parameters parsing. I think that finding some kind of abstraction to make it simpler would be great.
vm/src/obj/objbyteinner.rs
Outdated
#[pyarg(positional_only, optional = false)] | ||
sub: PyObjectRef, | ||
#[pyarg(positional_only, optional = true)] | ||
start: OptionalArg<PyObjectRef>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be PyIntRef
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be Int or None so I have to accept PyObjectRef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do OptinalArg<PyIntRef>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe OptionalArg<Option<PyIntRef>>
? I'm not sure if Option
is FromArgs
yet, but it should be the specified type or Python None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using OptionalArg<Option<PyIntRef>>
, you mean this implementation in impl block (line 126)?
let start = match self.start {
OptionalArg::Present(Some(int)) => Some(int.as_bigint().clone()),
_ => None,
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I let it for now.
let start = match self.start {
OptionalArg::Present(Some(int)) => Some(int.as_bigint().clone()),
_ => None,
};
instead of
let start = match self.start.into_option() {
Some(Some(int)) => Some(int.as_bigint().clone()),
_ => None,
};
using into_option() isn't much shorter and I find it less explicit. what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They both look great to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rust clippy tool would probably suggest to use something like this:
let start = if let Some(Some(int)) = self.start.into_option() {
Some(int.as_bigint().clone())
} else {
None
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use clippy and non suggestion about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's especially handy when you have a match with only two options (basically an if-else case).
Sorry for the late response @jgirardet. I will try and finish going over all the PR soon. |
np @palaviv
it's far better like it. |
This looks way better :). |
PyByteInner doesn't implement PyValue so I can't use the default Either |
I think this change is ready for merge now? Thank you for reviewing the change. |
some refactoring
some more methods