Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'cpython': 0.05; 'differently.': 0.07; 'nasty': 0.07; 'python': 0.08; 'dict': 0.09; 'am,': 0.12; 'dictionaries': 0.16; 'predictable': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'cc:addr:python-list': 0.16; 'language': 0.16; 'url:bugs': 0.17; 'wrote:': 0.18; '>>>': 0.18; 'cc:no real name:2**0': 0.21; 'input': 0.22; 'header:In- Reply-To:1': 0.22; 'feb': 0.22; 'versions': 0.23; 'structure': 0.26; 'cc:2**0': 0.26; 'code.': 0.26; 'function': 0.27; 'random': 0.28; 'message-id:@mail.gmail.com': 0.29; 'assuming': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'hash': 0.30; 'kelly': 0.30; 'received:209.85.210.46': 0.30; 'received:mail- pz0-f46.google.com': 0.30; 'source': 0.32; 'thu,': 0.32; 'anyone': 0.32; 'there': 0.33; 'steven': 0.34; 'url:python': 0.35; 'two': 0.36; 'created': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'hold': 0.38; 'think': 0.38; 'data': 0.38; 'url:org': 0.39; 'received:209': 0.39; 'more': 0.61; 'your': 0.61; 'day': 0.68; 'order,': 0.73; 'salt': 0.77; 'serious': 0.78; '100%': 0.82; 'guarantee.': 0.84; 'nathan': 0.84; 'ubiquitous': 0.84; 'surprise': 0.97 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=CVcOaBO3qiFEwhjJ7qsfwjbi2AAc935W+fBV+mT6Tvs=; b=sq47WYI+fO0GlXf5XYgs1JyrwJR7Q3YeE+gDj2hW6rSGo7Gj0+eEIjhRXccb6Ca7a2 VG6kx9rkvJidrjE7p1DJN8wxNMUbfAFZQr0n3wNLqVNk5bYVv6jVBzVLz02l0Me63YZk NjhEORUDQE5d2rJFt+Wo52G+4aN2WkhQ+6ikc= MIME-Version: 1.0 In-Reply-To: <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Date: Thu, 9 Feb 2012 21:30:46 -0500 Subject: Re: frozendict From: Nathan Rice To: "Steven D'Aprano" 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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328841051 news.xs4all.nl 6925 [2001:888:2000:d::a6]:44966 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20131 On Thu, Feb 9, 2012 at 8:24 PM, Steven D'Aprano wrote: > On Thu, 09 Feb 2012 09:35:52 -0700, Ian Kelly wrote: > >> On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice >> wrote: >>> As I said, two dictionaries created from the same input will be the >>> same... >> >> That's an implementation detail, not a guarantee. =A0It will hold for >> current versions of CPython but not necessarily for other Python >> implementations. > > That day may be sooner than you think. It is very likely that in Python > 3.3, dict order will be randomized on creation as a side-effect of adding > a random salt to hashes to prevent a serious vulnerability in dicts. > > http://securitytracker.com/id/1026478 > > http://bugs.python.org/issue13703 > > > If there is anyone still assuming that dicts have a predictable order, > they're going to be in for a nasty surprise one of these days. The only thing needed to avoid the hash collision is that your hash function is not not 100% predictable just by looking at the python source code. I don't see why every dict would have to be created differently. I would think having the most ubiquitous data structure in your language be more predictable would be a priority. Oh well.... Nathan