| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
|
||
| impl Iterable for PyArray { | ||
| fn iter(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyResult { | ||
| let zelf_ = zelf.clone(); |
There was a problem hiding this comment.
| let zelf_ = zelf.clone(); |
Sorry, something went wrong.
|
|
||
| impl Iterable for PyArray { | ||
| fn iter(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyResult { | ||
| let zelf_ = zelf.clone(); |
There was a problem hiding this comment.
_ prefix usually means unused variable in rust code.
Sorry, something went wrong.
There was a problem hiding this comment.
The _ suffix usually indicates that you're dodging the use of a reserved keyword. From the Rust style guide:
When a name is forbidden because it is a reserved word (e.g., crate), use a trailing underscore to make the name legal (e.g., crate_), or use raw identifiers if possible.
Sorry, something went wrong.
| let zelf_ = zelf.clone(); | ||
| Ok(PyArrayIter { | ||
| position: AtomicUsize::new(0), | ||
| array: zelf, |
There was a problem hiding this comment.
| array: zelf, | |
| array: zelf.clone(), |
change here to allow to use zelf later.
Sorry, something went wrong.
| Ok(PyArrayIter { | ||
| position: AtomicUsize::new(0), | ||
| array: zelf, | ||
| internal: PyMutex::new(PositionIterInternal::new(zelf_, 0)), |
There was a problem hiding this comment.
| internal: PyMutex::new(PositionIterInternal::new(zelf_, 0)), | |
| internal: PyMutex::new(PositionIterInternal::new(zelf.clone(), 0)), |
Is PositionIterInternal necessary for implementing __reduce__?
Sorry, something went wrong.
There was a problem hiding this comment.
oh, this is a good point. internal is doing nothing here. it must be position.
Sorry, something went wrong.
There was a problem hiding this comment.
The implementation was implemented by referring to the implementation of list iter.
Is there any reason to use zelf as it is instead of zelf.clone in list iter?
Sorry, something went wrong.
There was a problem hiding this comment.
I think @Snowapril got confused here. because zelf is already moved in upper line, it can't be cloned here.
Sorry, something went wrong.
|
Please do not use git merge. Would you try to rebase it? |
Sorry, something went wrong.
| pub struct PyArrayIter { | ||
| position: AtomicUsize, | ||
| array: PyArrayRef, | ||
| internal: PyMutex<PositionIterInternal<PyArrayRef>>, |
There was a problem hiding this comment.
do you really need both position and internal? Though I didn't look in details, those fields look like duplication.
Sorry, something went wrong.
There was a problem hiding this comment.
Is it because internal contains position because it is PositionIterInternal as its name suggests?
Sorry, something went wrong.
There was a problem hiding this comment.
Check the PositionIterInternal type. it contains position field. By this change, the code have duplicated position fields but most of code uses position and new code uses internal. I don't think it can correctly work
Sorry, something went wrong.
There was a problem hiding this comment.
With comparison with other types' iterator, we really don't need position and array field because PyMutex<PositionIterInternal<PyArrayRef>> will do their roles. Because of __next__ and __setstate__, we need to modify position and array fields. It leads to the need for PyMutex.
Sorry, something went wrong.
There was a problem hiding this comment.
If we replace position and array fields with PyMutex<PositionIterInternal<PyArrayRef>>, we can implement other methods as usual we did (__next__ and __reduce__)
Sorry, something went wrong.
There was a problem hiding this comment.
Does arrayiterator require closed field? I thought it only need position.
closed is useful when it include another iterator in it.
Sorry, something went wrong.
The following commands should get you started: git switch main
git pull upstream main
git checkout arrayiter_reduce
git rebase -i main
|
Sorry, something went wrong.
|
because people sometimes use main as a working branch, I like to recommend to use upstream/main directly git fetch upstream git rebase -i upstream/main this is same to git pull --rebase upstream main Though I never use pull. |
Sorry, something went wrong.
|
I'll use rebase from now on |
Sorry, something went wrong.
Co-authored-by: Yaminyam <siontama@gmail.com>
Co-authored-by: Yaminyam <siontama@gmail.com>
|
According to the CI, there are a few more tests to address. You can run the following command to take a closer look: cargo run --release --features ssl,jit -- -m test.test_array -vf
In addition, you can run cargo fmt --all to fix the formatting errors. |
Sorry, something went wrong.
Co-authored-by: Snowapril <sinjihng@gmail.com>
There was a problem hiding this comment.
thank you for contributing!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
No description provided.