-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Implement itertools.product #1526
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
0f614c1
to
b5b4835
Compare
|
||
#[derive(FromArgs)] | ||
struct ProductArgs { | ||
#[pyarg(keyword_only, optional = true)] |
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 an OptionalArg<usize>
to avoid having to check for an overflow yourself.
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.
Thanks!
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
vm/src/stdlib/itertools.rs
Outdated
struct PyIterToolsProduct { | ||
pools: Vec<Vec<PyObjectRef>>, | ||
idxs: RefCell<Vec<usize>>, | ||
cur: RefCell<usize>, |
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.
Is this separate sizes
Vec necessary? It seems like it's just the length of the Vec at the same index in pools
.
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.
Well, it can be implemented without separate sizes
but i don't know what's the benefit of not separating. Is there special reason, @coolreader18 ?
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.
Having them separate just seems redundant to me. I'd recommend removing sizes
and just using pools[i].len()
.
aa07112
to
038f486
Compare
vm/src/stdlib/itertools.rs
Outdated
#[pyimpl] | ||
impl PyIterToolsProduct { | ||
#[pyslot(new)] | ||
fn new( |
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.
tp_new
is the conventional name of this method
|
||
#[derive(FromArgs)] | ||
struct ProductArgs { | ||
#[pyarg(keyword_only, optional = true)] |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This implements `itertools.product` of standard library. Related with RustPython#1361
Well, it passes the snippet tests so I think yes. |
I think this looks good now! Thanks! |
This implements
itertools.product
of standard library.Related with #1361