Description
Feature
They are also relevant to inplace operations( iand
, isub
, ixor
).
CPython checks whether given argument and selfobject are equal and then returns.
intersection_update
: If self == arg, returns self.copy()difference_update
: If self == arg, returns self.clear(); Ok(())symmetric_difference_update
: If self == arg, returns self.clear(); Ok(())
At the current implementation, they get a parameter as SetIterable
which is converted from PyObjectRef
before entering each method.
For checking self == arg
, we should convert it after checking.
Python Documentation
- https://github.com/python/cpython/blob/3.10/Objects/setobject.c#L1627-L1630
- https://github.com/python/cpython/blob/3.10/Objects/setobject.c#L1410-L1412
- https://github.com/python/cpython/blob/3.10/Objects/setobject.c#L1186-L1189
Relevant Test Case
test_set.py
test_inplace_on_self