[docs] [issue20902] Which operand is preferred by set operations? Missing information in the documentation
report at bugs.python.org
Fri Mar 14 00:49:36 CET 2014
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 the two input sets and does membership testing over the LARGER set.
> In any case, this information should be made explicit in the docs
Not really. Historically, we've resisted the urge to over-specify or to declare something as undefined. In general, we make affirmative guarantees when they are useful and when we're prepared to make sure the guarantee will always hold (for example, it took a long while before sorts were guaranteed to be stable).
Another consideration is that for most users, additional notes of "behavior xxx is undefined" is confusing, disconcerting, distracting, and rarely helpful. Language lawyers tend to request this sort of wording out of some sense of completeness, but it doesn't actually make the docs better for users.
Python tracker <report at bugs.python.org>
More information about the docs