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


Groups > comp.lang.python > #25899

Re: dict: keys() and values() order guaranteed to be same?

References <jujc6j$rk5$1@speranza.aioe.org> <500D383A.9090500@phihag.de> <mailman.2462.1343044733.4697.python-list@python.org> <500d6bb2$0$29978$c3e8da3$5496439d@news.astraweb.com>
Date 2012-07-24 02:18 +1000
Subject Re: dict: keys() and values() order guaranteed to be same?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2487.1343060336.4697.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Jul 24, 2012 at 1:20 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> 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.

Of course, if I want splay tree semantics, I'd rather explicitly ask
for that. But it'd be legal.

ChrisA

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


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