Conversation
Sync the remote fork with upstream and pull to local branch
|
Search for |
|
I added How it works with Python 3: How it works with this implementation: |
|
The solution was to implement |
|
@Snowapril you may be interested in this |
youknowone
left a comment
There was a problem hiding this comment.
Looks good! I left a few suggestions about style and locks.
vm/src/stdlib/itertools.rs
Outdated
| match source { | ||
| Some(source) => match active { | ||
| Some(active) => { | ||
| Ok(vm.new_tuple((cls, vm.ctx.empty_tuple.clone(), (source, active)))) | ||
| } | ||
| None => Ok(vm.new_tuple((cls, vm.ctx.empty_tuple.clone(), (source,)))), | ||
| }, | ||
| None => Ok(vm.new_tuple((cls, vm.ctx.empty_tuple.clone()))), | ||
| } |
There was a problem hiding this comment.
| match source { | |
| Some(source) => match active { | |
| Some(active) => { | |
| Ok(vm.new_tuple((cls, vm.ctx.empty_tuple.clone(), (source, active)))) | |
| } | |
| None => Ok(vm.new_tuple((cls, vm.ctx.empty_tuple.clone(), (source,)))), | |
| }, | |
| None => Ok(vm.new_tuple((cls, vm.ctx.empty_tuple.clone()))), | |
| } | |
| let empty_tuple = vm.ctx.empty_tuple.clone(); | |
| let reduced = match source { | |
| Some(source) => match active { | |
| Some(active) => vm.new_tuple((cls, empty_tuple, (source, active))), | |
| None => vm.new_tuple((cls, empty_tuple, (source,))), | |
| }, | |
| None => vm.new_tuple((cls, empty_tuple)), | |
| }; | |
| Ok(reduced) |
vm/src/stdlib/itertools.rs
Outdated
| *zelf.source.write() = source.to_owned().try_into_value(vm)?; | ||
| *zelf.active.write() = active.to_owned().try_into_value(vm)?; |
There was a problem hiding this comment.
To avoid unpleasure broken synchronization, locking both and writing will be better.
| *zelf.source.write() = source.to_owned().try_into_value(vm)?; | |
| *zelf.active.write() = active.to_owned().try_into_value(vm)?; | |
| let mut source_lock = zelf.source.write(); | |
| let mut active_lock = zelf.active.write(); | |
| *source_lock = source.to_owned().try_into_value(vm)?; | |
| *active_lock = active.to_owned().try_into_value(vm)?; |
|
Thank you for contributing! |
Hello!
I tried to implement the
reducemethod forPyItertoolsChain(issue #3611) but got stuck. I used the CPython implementation as a reference. The implementation seems to work just fine with simple arrays etc. but fails thetest_chain_reducibletest. Any suggestions on why?The error message: