[docs] [issue32349] Add detailed return value information for set.intersection function

Mark Dickinson report at bugs.python.org
Sun Dec 17 13:28:43 EST 2017


Mark Dickinson <dickinsm at gmail.com> added the comment:

To clarify, are you referring to this behaviour?

>>> a = {1, 2, 3}
>>> b = {1.0, 4.0}
>>> a.intersection(b)  # expect {1}
{1.0}

I'd personally expect this to be implementation-dependent: since for set operations you usually only care about objects up to equality, it would be a bit unusual to care whether you get {1} or {1.0} in the above situation, and I'd say the implementation should be free to do whatever's convenient. Making documented guarantees would unnecessarily constrain other implementations.

I suppose one could document the *lack* of a guarantee here ...

----------
nosy: +mark.dickinson, rhettinger

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32349>
_______________________________________


More information about the docs mailing list