Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'explicitly': 0.04; '(although': 0.09; 'dict': 0.09; 'received:mail- vb0-f46.google.com': 0.09; 'subject:keys': 0.09; 'subject:same': 0.09; "wouldn't": 0.11; '24,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:values': 0.16; 'tables,': 0.16; 'wrote:': 0.17; 'received:209.85.212.46': 0.18; "i'd": 0.22; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'tree': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; "d'aprano": 0.29; 'dictionary': 0.29; 'enforce': 0.29; 'hash': 0.29; 'steven': 0.29; 'that.': 0.30; 'implement': 0.32; 'could': 0.32; 'to:addr:python-list': 0.33; 'likely': 0.33; 'received:google.com': 0.34; 'subject:?': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'does': 0.37; 'quite': 0.37; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'skip:n 10': 0.63; 'jul': 0.65; 'promise': 0.65; "it'd": 0.84; 'tree,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=NqFO3xZsDr+rKYaR+/vtSh1dWzAySIyHA0ObMkzy7+c=; b=eFEBiH/i5EY6pQza3EcKQulqQdBL+20UTHx4RXUK9+kriiotX/C+8WdBO8pXgBdRlv BJyrYU6VtStT7WocnKnSZhYahTfgAxqUf/MqHPa+grItkkNXjBOTeSBwkfSSYZN1L8zM 1wl6SB26/M/FIs+VNSIMiLRTVIZZgcIpK7BJDDyG54aoGNv63+kEGsFFB9QbjXWi28pF FsdmLWdbjS9maITg9/NdnNPiYjS6QxWnh291kr7JVYzVD4aCYu1bH0L4MlGTAVYGP2cG 8H5ul13MAxce++8BVesk/6TMDG9BcStVchFXtvHO/5ZFxxM465aCdVpAeqxjR/IHOfng HZoQ== MIME-Version: 1.0 In-Reply-To: <500d6bb2$0$29978$c3e8da3$5496439d@news.astraweb.com> References: <500D383A.9090500@phihag.de> <500d6bb2$0$29978$c3e8da3$5496439d@news.astraweb.com> Date: Tue, 24 Jul 2012 02:18:54 +1000 Subject: Re: dict: keys() and values() order guaranteed to be same? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1343060336 news.xs4all.nl 6891 [2001:888:2000:d::a6]:53876 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25899 On Tue, Jul 24, 2012 at 1:20 AM, Steven D'Aprano wrote: > (Although if you think about the implementation of dicts as hash tables, > it does seem likely that it is trivial to enforce this -- one would have > to work *harder* to break that promise than to keep it.) However, it would be quite reasonable to implement a dict as a splay tree, and have values() return them nearest-first. This would mean that just reading from the dictionary could change the order of values(), yet it wouldn't make the implementation non-conformant. Of course, if I want splay tree semantics, I'd rather explicitly ask for that. But it'd be legal. ChrisA