Python sets have these methods:
s.union(t) s | t new set with elements from both s and t
s.update(t) s |= t return set s with elements added from t
Likewise, there's also these:
s.intersection_update(t) s &= t return set s keeping only elements also found in t
s.intersection(t) s & t new set with elements common to s and t
And so on, for all the standard relational algebra operations.
What exactly is the difference here? I see that it says that the update() versions returns s instead of a new set, but if I write x = s.update(t)
, does that means that id(x) == id(s)
? Are they references to the same object now?
Why are both sets of methods implemented? It doesn't seem to add any significant functionality.