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


Groups > comp.lang.python > #93503

Re: Looking up a dictionary _key_ by key?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <lac@openend.se>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'test,': 0.05; 'implements': 0.07; 'iterate': 0.09; "object's": 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'tuple': 0.09; 'url:github': 0.09; 'cc:addr:python-list': 0.10; 'python': 0.11; '(key,': 0.16; 'compare.': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'iterable': 0.16; 'key?': 0.16; 'keys.': 0.16; 'py3': 0.16; 'pypi.': 0.16; 'subject:key': 0.16; 'unequal': 0.16; 'laura': 0.18; '>>>': 0.20; 'compare': 0.20; 'fix': 0.21; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'cc:no real name:2**0': 0.23; '2015': 0.23; 'header:In-Reply-To:1': 0.24; 'paul': 0.24; 'question': 0.26; 'looks': 0.29; '(maybe': 0.29; '-0700,': 0.29; 'dictionary': 0.29; 'equality': 0.29; 'received:se': 0.29; 'value)': 0.29; 'objects': 0.29; 'url:mailman': 0.31; 'fixed': 0.31; 'structure': 0.32; 'url:python': 0.33; 'problem': 0.33; "he's": 0.33; 'wrap': 0.33; 'subject:?': 0.34; 'url:listinfo': 0.35; 'could': 0.35; 'text': 0.36; 'url:org': 0.36; 'there': 0.36; 'subject:': 0.36; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'missing': 0.37; 'tue,': 0.38; 'data': 0.40; 'avoid': 0.61; 'header:Message-Id:1': 0.62; 'more': 0.62; 'details': 0.63; 'fundamental': 0.66; '>how': 0.84; 'fast,': 0.84; 'timing.': 0.84
To drsalists@gmail.com
cc python-list@python.org
From Laura Creighton <lac@openend.se>
Subject Re: Looking up a dictionary _key_ by key?
In-Reply-To Message from Paul Rubin <no.email@nospam.invalid> of "Tue, 23 Jun 2015 18:06:45 -0700." <87a8vpykwq.fsf@nightsong.com>
References <CAGGBd_pd9SA7SczanGARFr-+Z9SxP9Mkhfo-RivpcJLrnuexng@mail.gmail.com> <851th2t05t.fsf@benfinney.id.au> <CAGGBd_qaNC38Yg0u_b8+qBAckq6FRTZMxbWwuzV=MUYE_=ZzDw@mail.gmail.com> <mailman.3.1435107726.3674.python-list@python.org><87a8vpykwq.fsf@nightsong.com>
MIME-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-ID <30599.1436077538.1@theraft>
Date Sun, 05 Jul 2015 08:25:38 +0200
X-Greylist Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [127.0.0.1]); Sun, 05 Jul 2015 08:25:40 +0200 (CEST)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.301.1436077546.3674.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1436077546 news.xs4all.nl 2821 [2001:888:2000:d::a6]:38199
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:93503

Show key headers only | View raw


In a message of Tue, 23 Jun 2015 18:06:45 -0700, Paul Rubin writes:
>Chris Angelico <rosuav@gmail.com> writes:
>>> Would I have to do an O(n) search to find my key?
>> Iterate over it - it's an iterable view in Py3 - and compare.
>
>I think the question was whether the O(n) search could be avoided, not
>how to do it.  I don't see a way to avoid it.  There is fundamental
>brokenness in having unequal objects compare as equal, and the breakage
>messes up the dictionary when those objects are used as keys.
>
>Solution is to either fix the object equality test, or wrap them in
>something (maybe a tuple containing the objects and the distinguishing
>fields that are missing from the original object's equality method) that
>treats unequal objects as unequal.
>-- 
>https://mail.python.org/mailman/listinfo/python-list

This just showed up in my mailbox:

     Subject: [ANN] pyskiplist-1.0.0
     From:    Geert Jansen <geertj@gmail.com>

     PySkipList is a fast, pure Python implementation of an indexable
     skiplist. It implements a SkipList data structure that provides an
     always sorted, list-like data structure for (key, value) pairs.

... more details including timing.  For the full text see
https://github.com/geertj/pyskiplist
It's also available on PyPI.

Looks to me as if he's fixed the 0(n) problem ....

Laura

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


Thread

Re: Looking up a dictionary _key_ by key? Chris Angelico <rosuav@gmail.com> - 2015-06-24 11:02 +1000
  Re: Looking up a dictionary _key_ by key? Paul Rubin <no.email@nospam.invalid> - 2015-06-23 18:06 -0700
    Re: Looking up a dictionary _key_ by key? Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-24 00:50 -0600
      Re: Looking up a dictionary _key_ by key? Marko Rauhamaa <marko@pacujo.net> - 2015-06-24 09:55 +0300
    Re: Looking up a dictionary _key_ by key? Laura Creighton <lac@openend.se> - 2015-07-05 08:25 +0200

csiph-web