frozendict

Nathan Rice nathan.alexander.rice at gmail.com
Thu Feb 9 09:36:12 EST 2012


On Thu, Feb 9, 2012 at 5:33 AM, Duncan Booth
<duncan.booth at invalid.invalid> wrote:
> Nathan Rice <nathan.alexander.rice at gmail.com> wrote:
>
>> 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 hope you sort the items before putting them in a tuple, otherwise how do
> you handle two identical dicts that return their items in a different
> order?

Two dicts created from the same inputs will return items in the same
arbitrary order.  As long as you don't insert or delete a key you're
fine.


Nathan



More information about the Python-list mailing list