difference
is the only method that could stop early but doesn’t:
other = iter([1, 2, 3, 4, 5])
print({3, 4}.isdisjoint(other), *other)
other = iter([1, 2, 3, 4, 5])
print({1, 3}.issubset(other), *other)
other = iter([1, 2, 3, 4, 5])
print({1, 2}.issuperset(other), *other)
other = iter([1, 2, 3, 4, 5])
print({1, 3}.intersection(other), *other)
other = iter([1, 2, 3, 4, 5])
print({1, 3}.difference(other), *other)
Output (Attempt This Online!):
False 4 5
True 4 5
False 4 5
{1, 3} 4 5
set()
All the others stop early, leaving the iterator with 4 and 5 left. Only difference
doesn’t, even though it could.
(union
and symmetric_difference
also don’t stop early, but they of course can’t, as any further element might need to be added.)