Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20055

Re: Re: frozendict

Date 2012-02-08 23:33 -0600
From Evan Driscoll <driscoll@cs.wisc.edu>
Subject Re: Re: frozendict
References <4F332007.9080800@wisc.edu> <jgv9ps$35g$1@dough.gmane.org> <CAOFbRmJFjQU2sr3Jir1S1vZY=ppREx_a3jEY80di5NPzLYLzqA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5570.1328765634.27778.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 13:59, Nathan Rice wrote:
>> Turn the question around: why should there be?
>> Python is intentionally parsimonious in adding builtins.
> 
> For the same reason there are frozensets?
> 
> I put dicts in sets all the time.  I just tuple the items, but that
> means you have to re-dict it on the way out to do anything useful with
> it.  I am too lazy to write a frozendict or import one, but I would
> use it if it was a builtin.

I've wanted to do that as well.

My current use case is I want to have a dict as an attribute of another
object, and I want to use that object as a key in a dictionary. That
means that the outer object has to be immutable (an obnoxious enough
task on its own, BTW) and that either the dict itself has to be excluded
from computing the hash or the dict also has to be immutable.


Also, it's not like it has to be a builtin, per se. I know how to spell
'import'. :-)

Evan

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Re: frozendict Evan Driscoll <driscoll@cs.wisc.edu> - 2012-02-08 23:33 -0600

csiph-web