Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.055 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; '>>>>': 0.09; 'dict': 0.09; 'appropriate)': 0.16; 'dictionaries': 0.16; '\xa0as': 0.16; 'cc:addr:python-list': 0.16; 'insert': 0.19; 'cc:no real name:2**0': 0.21; 'input': 0.22; 'header:In-Reply-To:1': 0.22; 'appear': 0.23; 'calls.': 0.23; 'cc:2**0': 0.26; 'order.': 0.28; 'message-id:@mail.gmail.com': 0.29; 'fine.': 0.29; 'cc:addr:python.org': 0.29; '(and': 0.30; 'hash': 0.30; 'none,': 0.30; 'received:209.85.210.46': 0.30; 'received:mail- pz0-f46.google.com': 0.30; 'values': 0.32; 'keys': 0.34; 'two': 0.36; 'sequence': 0.37; 'created': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; "i'd": 0.39; 'received:209': 0.39; 'your': 0.61; 'guarantee': 0.66; 'order,': 0.73; 'guaranteed': 0.77; 'nathan': 0.84; 'order:': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=rvF4PTgLXYXI+FoA9of8U0mE//ZEl7XFkPDIrPzUW0o=; b=ivSjkSpeTiqbN2uoDOJEckYVlqxd3y/TJPUDnOGiHnk3gU/TcysOmQpUjfWjuLDrp2 GiRgEdrVIhTbq0uySZn/gFhuAwSKfBehSJMCf98VjH3ioVefyh6TgrNVKUIXzDTzlUEG ji5g3Nf1a7qw10WPQSd99irBUtWonQ3bN1zb8= MIME-Version: 1.0 In-Reply-To: References: <4F332007.9080800@wisc.edu> Date: Thu, 9 Feb 2012 10:19:46 -0500 Subject: Re: frozendict From: Nathan Rice To: duncan.booth@suttoncourtenay.org.uk Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328800790 news.xs4all.nl 6975 [2001:888:2000:d::a6]:39890 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20081 >> Two dicts created from the same inputs will return items in the same >> arbitrary order. =A0As long as you don't insert or delete a key you're >> fine. >> > Two dicts that contain the same keys and values may or may not return the= m > in the same order: > >>>> dict.fromkeys('ia') > {'i': None, 'a': None} >>>> dict.fromkeys('ai') > {'a': None, 'i': None} > > Would your system count those two dicts as the same? > > If the sequence in which the keys were added to the dict (and deleted if > appropriate) is exactly the same then it is likely but still not guarante= ed > that they will have the same order. The only ordering guarantee is that > within a single dict keys and values will appear in a consistent order so > long as you don't add/delete keys between calls. As I said, two dictionaries created from the same input will be the same... 'ai' !=3D 'ia'. If I need to hash a dict that I don't know was created in a deterministic order, I'd frozenset(thedict.items()). Nathan