On 07.07.20 17:37, Inada Naoki wrote:
On Tue, Jul 7, 2020 at 10:52 PM Dominik Vilsmeier
<dominik.vilsme...@gmx.de> wrote:
Surely that must be a relic from pre-3.7 days where dicts were unordered
and hence order-based comparison wouldn't be possible (though PEP 3106
describes an O(n*m) algorithm). However the current behavior is
unfortunate because it might trick users into believing that this is a
meaningful comparison between distinct objects (given that it works with
`dict.keys` and `dict.items`) when it isn't.
So why not make dict_values a Sequence, providing __getitem__ and
additionally order-based __eq__ comparison?
It was rejected in this thread.
https://mail.python.org/archives/list/python-...@python.org/thread/R2MPDTTMJXAF54SICFSAWPPCCEWAJ7WF/#K3SYX4DER3WAOWGQ4SPKCKXSXLXTIVAQ
All right, I see that having __eq__ for dict_values is not for debate.
But what about the other idea, making dict_values a Sequence? It does
provide some useful features, like getting the first value of a dict or
`.count` values.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/NXYRTCNYBGHJ7743N2AKPI2HDISQD4XB/
Code of Conduct: http://python.org/psf/codeofconduct/