On Tue, Oct 16, 2018 at 7:02 PM George Leslie-Waksman <waks...@gmail.com> wrote:
>
> Would a frozendict require that keys and values be hashable?

Keys would already have to be hashable - regular dicts demand this,
and there's no reason not to for frozendict.

Values? Not so sure. Personally I would say that no, they don't HAVE
to be hashable - but that the frozendict itself would then not be
hashable.

> It seems to me that we would need this restriction to make a reasonably 
> universal frozendict that is, itself, hashable.
>

The tuple provides a good precedent here:

>>> hash((1,2,3))
2528502973977326415
>>> hash((1,2,[]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
>>>

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to