Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'value,': 0.04; 'allowed.': 0.07; 'fix.': 0.09; 'subject:iterable': 0.09; 'cc:addr:python- list': 0.11; 'bug,': 0.16; 'dict': 0.16; 'expression.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'pairs': 0.16; 'pairs,': 0.16; 'then?': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'reset': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'possibly': 0.26; 'values': 0.27; 'gets': 0.27; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'flags': 0.31; 'keys': 0.31; 'sep': 0.31; 'steven': 0.31; 'fri,': 0.33; "can't": 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'list': 0.37; 'starting': 0.37; 'whatever': 0.38; 'pm,': 0.38; 'generating': 0.39; 'easy': 0.60; 'back': 0.62; 'offer': 0.62; 'zip': 0.64; 'subject:there': 0.68; 'guarantee.': 0.84; 'subject:check': 0.84; 'to:none': 0.92; 'state.': 0.95 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:cc :content-type; bh=8wpmD6Onh02HpN1+Xk31t3BGUGxq33vKZZtP4MeqBXE=; b=zolGp6fA1WQkBL6zdhCDjYVu2KCeoNp99+NxqNAvQK4T42QzUlBUyrIisOVqQ/lC8A WfZXOmYxWh5Tk0/xGvKo00OOQkjWa+MnMcp3Qm3nlOqzZ1zj9IMTtn2RSyH4ZjAO/krn mt7wzMQlbuiJ4b3ViDKZ2j8AWeODa1dNuZGl2cCEQYXIxcI4Anks+lCTyrsm1NXu5g3D wZBV36+G5jlBnq2Gpij3IP48zFmpdDds3nywe1hMBo5wnn36u9pbuKL6GbBntz15hfSL M2/ddmS3NvWgC1+wm5zWgI14jsU3Tc4Qt6Zx8ZEM2EnSL7No0Yj5McidrwHdIgChySaV NRBw== MIME-Version: 1.0 X-Received: by 10.50.20.169 with SMTP id o9mr26053282ige.14.1411127765742; Fri, 19 Sep 2014 04:56:05 -0700 (PDT) In-Reply-To: <541c177a$0$29969$c3e8da3$5496439d@news.astraweb.com> References: <541bbbe6$0$29982$c3e8da3$5496439d@news.astraweb.com> <541c0c7d$0$29992$c3e8da3$5496439d@news.astraweb.com> <541c177a$0$29969$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 19 Sep 2014 21:56:05 +1000 Subject: Re: Is there a canonical way to check whether an iterable is ordered? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1411127768 news.xs4all.nl 2958 [2001:888:2000:d::a6]:51523 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78073 On Fri, Sep 19, 2014 at 9:46 PM, Steven D'Aprano wrote: > Chris Angelico wrote: > >> On Fri, Sep 19, 2014 at 8:59 PM, Steven D'Aprano >> wrote: >>> Here's a proof of concept of what would be allowed: > [...] >> Also, this can't possibly offer the same guarantee. Watch: >> >> d = MyDict(some_lot_of_items) >> d.values(); d.items() >> # mutate the dict in whatever way you like >> pairs = zip(d.keys(), d.values()) >> >> This might well create mismatched pairs, because after generating the >> keys() return value, the list gets shuffled, prior to generating >> values() in the same expression. This would not be allowed. > > That would be a bug, and an easy one to fix. Every mutation of the dict > would have to reset the internal flags back to the starting state. What if there's no mutation, then? Just calling values() and items() means that the zip of keys and values will make mismatches. ChrisA