Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'modified': 0.05; 'calls.': 0.07; '(although': 0.09; 'dict': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'subject:keys': 0.09; 'subject:same': 0.09; '~ethan~': 0.09; "wouldn't": 0.11; '24,': 0.16; 'received:69.41.248': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'subject:values': 0.16; 'tables,': 0.16; 'wrote:': 0.17; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'chris': 0.28; "d'aprano": 0.29; 'dictionary': 0.29; 'enforce': 0.29; 'hash': 0.29; 'steven': 0.29; 'implement': 0.32; 'could': 0.32; 'docs': 0.33; 'to:addr:python-list': 0.33; 'likely': 0.33; 'subject:?': 0.35; 'does': 0.37; 'quite': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'between': 0.63; 'skip:n 10': 0.63; 'jul': 0.65; 'promise': 0.65; 'tree,': 0.84 Date: Thu, 26 Jul 2012 14:06:03 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: python-list@python.org Subject: Re: dict: keys() and values() order guaranteed to be same? References: <500D383A.9090500@phihag.de> <500d6bb2$0$29978$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.10.136]) [72.11.125.166]:1325 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 3 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1343336468 news.xs4all.nl 6856 [2001:888:2000:d::a6]:49017 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26115 Chris Angelico wrote: > 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. Yes, it would. The docs say that .keys(), .values(), etc., will maintain order unless the dict is modified in between calls. ~Ethan~