[Python-ideas] Dictionary views are not entirely 'set like'
Wes Turner
wes.turner at gmail.com
Wed Apr 6 16:40:01 EDT 2016
On Apr 6, 2016 7:50 AM, "Random832" <random832 at fastmail.com> wrote:
>
> On Wed, Apr 6, 2016, at 05:38, Joshua Morton wrote:
> > {}.keys() == {}.keys() # 7
> > {}.items() == {}.items() # 8
> > {}.values() == {}.values() # 9
> > d = {}; d.values() == d.values() # 10
> >
> > True, True, False, False.
> >
> > Numbers 1, 2, 4, 5 are expected behavior. 3 and 6 are not, and 7-10 is
up
> > for debate.[1]
>
> Last time this came up, the conclusion was that making values views
> comparable was intractable due to the fact that they're unordered but
> the values themselves aren't hashable. Then the discussion got
> sidetracked into a discussion of whether the justification for not
> having them be hashable (Java does just fine with everything being
> hashable and content-based hashes for mutable objects) makes sense in a
> "consenting-adults" world.
With e.g. OrderedDict, one practical solution is to subclass and wrap
.keys() in a set and .values() in a list.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160406/20967816/attachment.html>
More information about the Python-ideas
mailing list