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: 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 Subject: Re: Looking up a dictionary _key_ by key? In-Reply-To: Message from Paul Rubin of "Tue, 23 Jun 2015 18:06:45 -0700." <87a8vpykwq.fsf@nightsong.com> References: <851th2t05t.fsf@benfinney.id.au> <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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 In a message of Tue, 23 Jun 2015 18:06:45 -0700, Paul Rubin writes: >Chris Angelico 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 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