[issue20902] Which operand is preferred by set operations? Missing information in the documentation

Raymond Hettinger report at bugs.python.org
Sat Mar 15 21:52:23 CET 2014


Raymond Hettinger added the comment:

Thanks Terry.  

And yes, your reading of the set.update() docs is correct, "Update the set, adding elements from all others" means that it updates the set by adding the elements from the other sets.

FWIW, getting into details about "which value wins" goes against the core concept of the data structure.  Sets (in a mathematical sense) are about treating elements of an equivalence class as being identical.  We intentionally treat {1, 1.1} as being of length one and equal to {1.1, 1} eventhough the integer 1 and the float 1.0 are actually distinguishable in ways not tested by equality.

This isn't just a concept with sets.  The dict.update() method works similarly as does other container operations that depend on a notion of equivalence that is independent of other distinctive traits (object identity, attached values, type, etc).

----------
resolution:  -> invalid
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20902>
_______________________________________


More information about the Python-bugs-list mailing list