This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author harahu
Recipients docs@python, eric.araujo, ezio.melotti, harahu, mdk, willingc
Date 2021-11-17.19:00:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>

> For container types such as list, tuple, set, frozenset, dict, or collections.deque, the expression `x in y` is equivalent to `any(x is e or x == e for e in y)`.


import pandas as pd
import numpy as np

pd_0_dt = pd.Timedelta(0)
np_0_dt = np.timedelta64(0)

cm = (pd_0_dt, np_0_dt)

d1 = {np_0_dt: pd_0_dt}
d2 = {pd_0_dt: np_0_dt}

def test_membership_doc_claim(candidate_members, dct):
    for m in candidate_members:
        if m in dct:
            assert any(m is e or m == e for e in dct)

        if any(m is e or m == e for e in dct):
            assert m in dct

if __name__ == "__main__":
    test_membership_doc_claim(cm, d1) # Fails
    test_membership_doc_claim(cm, d2) # Fails


Not too surprised, given the td.__hash__() implementation differs between these classes, but they are considered equal none the less.

Unsure whether it is the dict implementation or the doc claim that needs to budge here.
Date User Action Args
2021-11-17 19:00:34harahusetrecipients: + harahu, ezio.melotti, eric.araujo, docs@python, willingc, mdk
2021-11-17 19:00:34harahusetmessageid: <>
2021-11-17 19:00:34harahulinkissue45832 messages
2021-11-17 19:00:34harahucreate