[issue45832] Misleading membersip expression documentation
Raymond Hettinger
report at bugs.python.org
Wed Nov 17 15:29:30 EST 2021
Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
This section presumes that the usual hash invariant holds: a==b implies hash(a)==hash(b). We could repeat that here but I don't think it makes the docs better or more useable to require that docs repeat the same facts in multiple places.
Alternatively, the sentence could be split to cover both cases:
"""
For sequence container types such as list, tuple, or collections.deque,
the expression `x in y` is equivalent to `any(x is e or x == e for e in y)`.
For container that use hashing, such as dict, set, or frozenset,
the expression `x in y` is equivalent to `any(x is e or x == e for e in y if hash(x) == hash(e))`.
"""
While that is more precise, it borders on being pedantic and likely doesn't make the average reader better off.
Consider submitting a feature request to pandas suggesting that they harmonize their hash functions with their counterparts in numpy.
----------
nosy: +rhettinger
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45832>
_______________________________________
More information about the Python-bugs-list
mailing list