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
Terry J. Reedy added the comment:
Defining equality to ignore the .value attribute (and the id), says that they
*do not matter*. Python believes you and the interpreter does what it does. If
we had made a 'first or second operand wins' claim, we would not have been able
to optimize
Giacomo Alzetta added the comment:
I asked this because, for example, in Haskell it *is* a well-defined behaviour
(see its documentation at:
http://hackage.haskell.org/package/containers-0.5.4.0/docs/Data-Set.html): the
left operand is preferred by all operations.
In fact, working with
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
assignee: docs@python - rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20902
___
Raymond Hettinger added the comment:
As far as I can tell currently there is no rule about this.
Intersection prefers the second operand, while union prefers the first.
The implementation uses the same logic as found in Lib/sets.py where the
intersection operator loops over the SMALLER of
New submission from Giacomo Alzetta:
Currently the documentation for set (at:
http://docs.python.org/2/library/stdtypes.html#set) does not mention which
operand is preferred when performing the usual binary operations.
For example the following sample code doesn't have a defined result
R. David Murray added the comment:
If you take the intersection or union of a set, it shouldn't matter which set
the element came from, by the axioms that apply to sets. So it if does,
that's an application bug, IMO.
--
nosy: +r.david.murray
___
Changes by Éric Araujo mer...@netwok.org:
--
nosy: +stutzbach
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20902
___
___
Python-bugs-list mailing
R. David Murray added the comment:
Or, to put it another way, which set it comes from is not documented because it
is an implementation detail and can not be depended on.
I'm sure someone will correct me if I'm wrong :)
--
nosy: +rhettinger
___
Steven D'Aprano added the comment:
If this is undefined, and I think it should be, the docs should explicitly say
so. How is this?
The union and intersection operations select elements which appear in both
operands, e.g. set([a, b, c]) set([c, d, e]) returns set([c]). The selection
is
R. David Murray added the comment:
Sounds good to me.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20902
___
___
Python-bugs-list mailing list
Changes by Balakrishnan B balakrishnan.er...@gmail.com:
--
nosy: +Balakrishnan.B
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20902
___
___
Changes by Benjamin Peterson bp+pyb...@benjamin-peterson.org:
--
keywords: +easy
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20902
___
___
13 matches
Mail list logo