Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78075

Re: Is there a canonical way to check whether an iterable is ordered?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'correspond': 0.09; 'iterate': 0.09; 'keys,': 0.09; 'oh,': 0.09; 'subject:iterable': 0.09; 'cc:addr:python-list': 0.11; 'dict': 0.16; 'fails.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'interpreter,': 0.16; 'iterables': 0.16; 'modified.': 0.16; 'sure.': 0.16; 'wrote:': 0.18; 'rules': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'this:': 0.26; 'second': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'assert': 0.31; "d'aprano": 0.31; 'keys': 0.31; 'sep': 0.31; 'steven': 0.31; 'run': 0.32; 'says': 0.33; 'fri,': 0.33; 'guess': 0.33; 'problem': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'changing': 0.37; 'being': 0.38; 'pm,': 0.38; 'first': 0.61; 'back': 0.62; 'promise': 0.68; 'subject:there': 0.68; 'other.': 0.75; 'dict,': 0.84; 'subject:check': 0.84; 'to:none': 0.92
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=UycjDAm+MJrgRDGEe8YTjAJKTeac9QB8tmlxVW2AeHw=; b=Vq9x6i8bWRSTT3vdelGWf1zurHr1ua+jDB+TJMb0seI7rrEttFc+J7XsFHnh7tO03m ZmCNdCrqPTlsTnH7onmO94rtX6rHi/A+YEBRG9wVIkBm1CyL0gKltdDY2HS/B3T+fgvj xZ6ZKltbjxxMEl+HD51DlYz49Dd35qjEsVruXi2R1cF1Kq+3x04dxAscTzpt8IIYyCcC iHx4MxukxT45Ijs+Y91Vw8dX4+GTCUMZGnkA62hXitXNPct9Ya1vEXDryAioGqQoR8g1 5z77bUjfc9uU2h4/F3RaHR8MFuDsekwAa5OLG59oCov9pRUvAMzKjSwQv8lwpmL5G/1P P7Qw==
MIME-Version 1.0
X-Received by 10.50.66.234 with SMTP id i10mr39792794igt.34.1411128407566; Fri, 19 Sep 2014 05:06:47 -0700 (PDT)
In-Reply-To <541c1a7b$0$29976$c3e8da3$5496439d@news.astraweb.com>
References <efcc61e6-f132-4f14-80b5-0536816b6c7b@googlegroups.com> <mailman.14101.1411042251.18130.python-list@python.org> <roy-E21095.08580518092014@news.panix.com> <541bbbe6$0$29982$c3e8da3$5496439d@news.astraweb.com> <mailman.14134.1411105214.18130.python-list@python.org> <541c0c7d$0$29992$c3e8da3$5496439d@news.astraweb.com> <mailman.14140.1411125602.18130.python-list@python.org> <541c1a7b$0$29976$c3e8da3$5496439d@news.astraweb.com>
Date Fri, 19 Sep 2014 22:06:47 +1000
Subject Re: Is there a canonical way to check whether an iterable is ordered?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14144.1411128833.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1411128833 news.xs4all.nl 2884 [2001:888:2000:d::a6]:57977
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78075

Show key headers only | View raw


On Fri, Sep 19, 2014 at 9:58 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> All it says is that keys/values/items will correspond, not keys/keys, etc.
>
> Hmmm. On second thought, there is a problem with this:
>
> a = list(mydict)
> c = list(mydict.items())  # now the internal order is shuffled
> b = list(mydict.values())
> assert list(zip(a, b)) == c
>
> and the assertion fails.
>
> So I guess that rules out dict internal order changing during a single run
> of the interpreter, unless the dict is modified.

Precisely. If you iterate keys, keys, values with no mutations in
between, the first keys has to correspond to values, and the second
keys has to correspond to values, ergo they must correspond to each
other.

> Anyway, that's just dicts. Custom iterables can change any time they like.

Oh, sure. That's a very specific promise of the dict, nothing else.
The set might well randomize, if it wished. But we still come back to
there being no reason for it to change.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Is there a canonical way to check whether an iterable is ordered? cool-RR <ram.rachum@gmail.com> - 2014-09-18 04:55 -0700
  Re: Is there a canonical way to check whether an iterable is ordered? Chris Angelico <rosuav@gmail.com> - 2014-09-18 22:10 +1000
    Re: Is there a canonical way to check whether an iterable is ordered? Roy Smith <roy@panix.com> - 2014-09-18 08:58 -0400
      Re: Is there a canonical way to check whether an iterable is ordered? Chris Angelico <rosuav@gmail.com> - 2014-09-18 23:33 +1000
        Re: Is there a canonical way to check whether an iterable is ordered? Roy Smith <roy@panix.com> - 2014-09-18 19:52 -0400
          Re: Is there a canonical way to check whether an iterable is ordered? Chris Angelico <rosuav@gmail.com> - 2014-09-19 12:45 +1000
          Re: Is there a canonical way to check whether an iterable is ordered? Terry Reedy <tjreedy@udel.edu> - 2014-09-19 18:02 -0400
          Re: Is there a canonical way to check whether an iterable is ordered? Chris Angelico <rosuav@gmail.com> - 2014-09-20 15:01 +1000
      Re: Is there a canonical way to check whether an iterable is ordered? Terry Reedy <tjreedy@udel.edu> - 2014-09-18 09:46 -0400
      Re: Is there a canonical way to check whether an iterable is ordered? Tim Chase <python.list@tim.thechases.com> - 2014-09-18 09:32 -0500
      Re: Is there a canonical way to check whether an iterable is ordered? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-19 15:15 +1000
        Re: Is there a canonical way to check whether an iterable is ordered? Chris Angelico <rosuav@gmail.com> - 2014-09-19 15:40 +1000
          Re: Is there a canonical way to check whether an iterable is ordered? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-19 20:59 +1000
            Re: Is there a canonical way to check whether an iterable is ordered? Chris Angelico <rosuav@gmail.com> - 2014-09-19 21:19 +1000
              Re: Is there a canonical way to check whether an iterable is ordered? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-19 21:58 +1000
                Re: Is there a canonical way to check whether an iterable is ordered? Chris Angelico <rosuav@gmail.com> - 2014-09-19 22:06 +1000
            Re: Is there a canonical way to check whether an iterable is ordered? Chris Angelico <rosuav@gmail.com> - 2014-09-19 21:25 +1000
              Re: Is there a canonical way to check whether an iterable is ordered? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-19 21:46 +1000
                Re: Is there a canonical way to check whether an iterable is ordered? Chris Angelico <rosuav@gmail.com> - 2014-09-19 21:56 +1000
                Re: Is there a canonical way to check whether an iterable is ordered? alister <alister.nospam.ware@ntlworld.com> - 2014-09-19 12:26 +0000
                Re: Is there a canonical way to check whether an iterable is ordered? Chris Angelico <rosuav@gmail.com> - 2014-09-19 22:36 +1000
  Re: Is there a canonical way to check whether an iterable is ordered? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-19 15:04 +1000

csiph-web