-
Notifications
You must be signed in to change notification settings - Fork 921
remove redundant counters for remaining elements in set and frozenset iteration #5726
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
src/types/frozenset.rs
Outdated
|
|
||
| fn size_hint(&self) -> (usize, Option<usize>) { | ||
| (self.remaining, Some(self.remaining)) | ||
| let len = self.len(); |
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.
Do we need to call self.__length_hint__() here? (Or whatever the Rust/C name of that is.)
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.
Changed to call ExactSizeIterator::len to show where this value is coming from (that len does call size_hint of the underlying iterator, yes).
|
@davidhewitt Looks like there is some issue with this. On current main I get two ❯ cargo test --package pyo3 --lib -F abi3 -- types::frozenset::tests --nocapture
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.19s
Running unittests src\lib.rs (target\x86_64-pc-windows-gnullvm\debug\deps\pyo3-9eb94db30d3f0e35.exe)
running 8 tests
test types::frozenset::tests::test_frozenset_builder ...
thread 'types::frozenset::tests::test_iter_count' (8760) panicked at src\types\frozenset.rs:348:13:
assertion `left == right` failed
left: 0
right: 3
oknote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test types::frozenset::tests::test_iter_count ... FAILED
thread 'types::frozenset::tests::test_frozenset_iter_size_hint' (9804) panicked at src\types\frozenset.rs:315:13:
assertion `left == right` failed
left: 0
right: 1
test types::frozenset::tests::test_frozenset_iter ... ok
test types::frozenset::tests::test_frozenset_iter_bound ... ok
test types::frozenset::tests::test_frozenset_empty ... ok
test types::frozenset::tests::test_frozenset_iter_size_hint ... FAILED
test types::frozenset::tests::test_frozenset_contains ... ok
test types::frozenset::tests::test_frozenset_new_and_len ... ok
failures:
failures:
types::frozenset::tests::test_frozenset_iter_size_hint
types::frozenset::tests::test_iter_count
test result: FAILED. 6 passed; 2 failed; 0 ignored; 0 measured; 763 filtered out; finished in 0.03s |
|
I think the problem is that |
|
#5727 should have enabled |
|
Oh, weird it looks like local git history just skipped #5727 even though it had this on in it... Not sure how that happed 🤔 but I fixed it now and the issue went away. Sorry for the noise. |
|
No prob, strange git bug! |
Related to #5661
This PR removes counters for remaining values from
setandfrozensetiterators; the underlying Python iterators already have this information and we can query it when needed.While touching the code, I replaced some
.unwrap()calls to.expect()to improve self-documentation slightly.