Skip to content

Fix set intersection_update implementation #5405

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Lib/test/test_weakset.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,6 @@ def test_ixor(self):
else:
self.assertNotIn(c, self.s)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_inplace_on_self(self):
t = self.s.copy()
t |= t
Expand Down
12 changes: 3 additions & 9 deletions vm/src/builtins/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,10 @@ impl PySetInner {
others: impl std::iter::Iterator<Item = ArgIterable>,
vm: &VirtualMachine,
) -> PyResult<()> {
let mut temp_inner = self.copy();
let temp_inner = self.fold_op(others, PySetInner::intersection, vm)?;
self.clear();
for iterable in others {
for item in iterable.iter(vm)? {
let obj = item?;
if temp_inner.contains(&obj, vm)? {
self.add(obj, vm)?;
}
}
temp_inner = self.copy()
for obj in temp_inner.elements() {
self.add(obj, vm)?;
}
Ok(())
}
Expand Down
Loading