Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #15311
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python.list@tim.thechases.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'bug': 0.02; 'cpython': 0.05; 'terry': 0.07; 'assert': 0.09; 'dict': 0.09; 'cc:addr :python-list': 0.15; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'iterates': 0.16; 'message-id:@tim.thechases.com': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.21; 'is?': 0.21; 'maybe': 0.21; '(or': 0.22; 'items.': 0.23; "shouldn't": 0.23; 'header:In-Reply-To:1': 0.23; 'cc:2**0': 0.25; '(and': 0.28; 'depends': 0.28; 'cc:addr:python.org': 0.29; 'hash': 0.30; 'list1': 0.30; 'url:library': 0.30; "didn't": 0.30; 'least': 0.31; 'changes': 0.32; 'does': 0.32; 'sort': 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'hold': 0.35; 'url:python': 0.35; 'anything': 0.36; 'depend': 0.36; 'entry': 0.37; 'but': 0.37; 'two': 0.37; 'experience,': 0.38; 'url:org': 0.38; 'url:docs': 0.38; 'subject:: ': 0.39; 'order': 0.62; 'saw': 0.67; 'order,': 0.73; 'it"': 0.84 |
| Date | Thu, 03 Nov 2011 18:01:38 -0500 |
| From | Tim Chase <python.list@tim.thechases.com> |
| User-Agent | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.20) Gecko/20110826 Icedove/3.1.12 |
| MIME-Version | 1.0 |
| To | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Dictionary sorting |
| References | <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> <j8v1h5$4mc$1@dough.gmane.org> |
| In-Reply-To | <j8v1h5$4mc$1@dough.gmane.org> |
| Content-Type | text/plain; charset=ISO-8859-1; 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 - boston.accountservergroup.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - tim.thechases.com |
| X-Source | |
| X-Source-Args | |
| X-Source-Dir | |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2418.1320361310.27778.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1320361310 news.xs4all.nl 6881 [2001:888:2000:d::a6]:48877 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:15311 |
Show key headers only | View raw
On 11/03/11 16:36, Terry Reedy wrote:
> > Is there a way to not sort them and leave the order as is?
>
> CPython iterates (and prints) dict items in their arbitrary internal
> hash table order, which depends on the number and entry order of the
> items. It is a bug to depend on that arbitrary order in any way.
Does this "never trust it" hold even for two consecutive
iterations over an unchanged dict? I didn't see anything in the
docs[1] to make such a claim, but at least from my experience,
one can reliably assert
d = {}
randomly_populate(d)
list1 = list(d.iterkeys())
list2 = list(d.iterkeys())
assert list1 == list2
I understand all bets are off if one adds/removes (or maybe
changes the values) of the dict between iterations, but I didn't
know if what I saw was merely an implementation detail that
shouldn't be counted on.
-tkc
[1]
http://docs.python.org/library/stdtypes.html#mapping-types-dict
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Dictionary sorting Scott Ware <scottdware@gmail.com> - 2011-11-03 11:46 -0700
Re: Dictionary sorting John Gordon <gordon@panix.com> - 2011-11-03 18:57 +0000
Re: Dictionary sorting Scott Ware <scottdware@gmail.com> - 2011-11-03 12:00 -0700
Re: Dictionary sorting Chris Kaynor <ckaynor@zindagigames.com> - 2011-11-03 12:13 -0700
Re: Dictionary sorting insomnia@gmail.com - 2011-11-03 13:01 -0700
Re: Dictionary sorting Terry Reedy <tjreedy@udel.edu> - 2011-11-03 17:36 -0400
Re: Dictionary sorting Tim Chase <python.list@tim.thechases.com> - 2011-11-03 18:01 -0500
Re: Dictionary sorting Ben Finney <ben+python@benfinney.id.au> - 2011-11-04 11:06 +1100
Re: Dictionary sorting Hrvoje Niksic <hniksic@xemacs.org> - 2011-11-04 11:20 +0100
Re: Dictionary sorting Ben Finney <ben+python@benfinney.id.au> - 2011-11-04 23:19 +1100
Re: Dictionary sorting Chris Angelico <rosuav@gmail.com> - 2011-11-04 10:59 +1100
csiph-web