Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25854
| 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!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| 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; 'pypy': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:keys': 0.09; 'subject:same': 0.09; 'correspond.': 0.16; 'dictionary,': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'intervening': 0.16; 'iteration': 0.16; 'message-id:@dough.gmane.org': 0.16; 'order?': 0.16; 'received:80.91.229.3': 0.16; 'received:mnet-online.de': 0.16; 'received:plane.gmane.org': 0.16; 'subject:values': 0.16; 'wrote:': 0.17; 'stefan': 0.17; 'tend': 0.17; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'common': 0.26; '[1]': 0.27; 'wonder': 0.27; 'structures': 0.27; 'header:X-Complaints-To:1': 0.28; 'all.': 0.28; 'yes.': 0.29; 'maybe': 0.29; 'expect': 0.31; 'lists': 0.31; 'url:python': 0.32; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'subject:?': 0.35; 'received:org': 0.36; 'really': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'should': 0.36; 'enough': 0.36; 'well.': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'build': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'easy': 0.60; 'details': 0.63; 'received:93': 0.72; 'adhere': 0.84; 'url:items': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Stefan Behnel <stefan_ml@behnel.de> |
| Subject | Re: dict: keys() and values() order guaranteed to be same? |
| Date | Mon, 23 Jul 2012 13:58:37 +0200 |
| References | <jujc6j$rk5$1@speranza.aioe.org> <500D383A.9090500@phihag.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | ppp-93-104-24-69.dynamic.mnet-online.de |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 |
| In-Reply-To | <500D383A.9090500@phihag.de> |
| 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.2462.1343044733.4697.python-list@python.org> (permalink) |
| Lines | 26 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1343044733 news.xs4all.nl 6851 [2001:888:2000:d::a6]:42798 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:25854 |
Show key headers only | View raw
Philipp Hagemeister, 23.07.2012 13:40: > On 07/23/2012 01:23 PM, Henrik Faber wrote: >> With an arbitrary dictionaty d, are d.keys() and d.values() >> guaraneed to be in the same order? > > Yes. From the documentation[1]: > > If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() > are called with no intervening modifications to the dictionary, the > lists will directly correspond. > > [1] http://docs.python.org/library/stdtypes.html#dict.items Interesting. I wonder if other implementations like Jython and PyPy really adhere to this official guarantee. At least Jython has the same paragraph in its documentation and I would expect that PyPy follows it as well. http://www.jython.org/docs/library/stdtypes.html#mapping-types-dict Maybe this guarantee is just easy enough to build on the given implementation details of a platform that it's a common property. Iteration over data structures should tend to be deterministic, after all. Stefan
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
dict: keys() and values() order guaranteed to be same? Henrik Faber <hfaber@invalid.net> - 2012-07-23 13:23 +0200
Re: dict: keys() and values() order guaranteed to be same? Philipp Hagemeister <phihag@phihag.de> - 2012-07-23 13:40 +0200
Re: dict: keys() and values() order guaranteed to be same? Henrik Faber <hfaber@invalid.net> - 2012-07-23 14:19 +0200
Re: dict: keys() and values() order guaranteed to be same? Stefan Behnel <stefan_ml@behnel.de> - 2012-07-23 13:43 +0200
Re: dict: keys() and values() order guaranteed to be same? Stefan Behnel <stefan_ml@behnel.de> - 2012-07-23 13:58 +0200
Re: dict: keys() and values() order guaranteed to be same? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-23 15:20 +0000
Re: dict: keys() and values() order guaranteed to be same? Chris Angelico <rosuav@gmail.com> - 2012-07-24 02:18 +1000
Re: dict: keys() and values() order guaranteed to be same? Ethan Furman <ethan@stoneleaf.us> - 2012-07-26 14:06 -0700
Re: dict: keys() and values() order guaranteed to be same? Ethan Furman <ethan@stoneleaf.us> - 2012-07-26 14:03 -0700
csiph-web