On Fri, Jan 24, 2020 at 5:24 PM Victor Stinner <vstin...@python.org> wrote:
>
> You're right that it's not only about list.count().
>
> list.count(), list.index(), tuple.count() and tuple.index() all
> consider that two elements are equal if id(x) == id(y):
>

FWIW, (list|tuple).__eq__ and (list|tuple).__contains__ uses it too.
It is very important to compare recursive sequences.

>>> x = []
>>> x.append(x)
>>> y = [x]
>>> z = [x]
>>> y == z
True

-- 
Inada Naoki  <songofaca...@gmail.com>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ILPWRGJOB4AFECGQHOH5LIZ7HPMACXX7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to