Implement dict doc & reversed magic method#2172
Conversation
| @@ -1,3 +1,5 @@ | |||
| import pytest | |||
There was a problem hiding this comment.
Unfortunately, pytest is running the test but not available from the test code. See testutils.py. it includes assert_raises function which almost working like pytest.raises
There was a problem hiding this comment.
Could you tell me how to cPython test in local? It's succeeded in local. but failed in CI
There was a problem hiding this comment.
README describes how to run test in local.
Roughly, running a single file is: python tests/snippets/builtin_dict.py
| match self.dict.len().checked_sub(count) { | ||
| Some(mut pos) => { | ||
| let (key, value) = self.dict.entries.next_entry(&mut pos).unwrap(); | ||
| self.position.store(count); |
There was a problem hiding this comment.
I think @palaviv was busy for a while. Because I don't want to keep this PR open for too long time, here is a suggestion:
let count = self.position.fetch_add(1);
match ... {
Some(..) => ... // we don't nees to store a new value here. it already was `fetch_add`ed. and this is the hot path
None => { self.position.store(std::isize::MAX as usize); ... } // prevent overflow here
}the position will keep the atomicity and it will not be a big problem to set the value when it is already done
There was a problem hiding this comment.
I fixed this issue, but i'm not sure it's what you expected.
There was a problem hiding this comment.
Thanks, it looks good to me. @coolreader18 is this ok?
|
You chose a big work as a first contriibution ;) the PR generally looks good. Normally, contributors never use Will you try to rebase your work? |
Thank you for your advice. Thanks to |
Implement a document and reversed feature of dictionary type.
Tests expect python 3.8 or higher (or RustPython)