Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'suppose': 0.05; 'python': 0.08; 'dict': 0.09; 'folks': 0.15; '(modulo': 0.16; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message- id:@tim.thechases.com': 0.16; 'okay,': 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; 'subject:independent': 0.16; 'values?': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; 'header :In-Reply-To:1': 0.22; 'interface': 0.23; 'tree.': 0.23; 'cc:2**0': 0.24; 'tree': 0.25; 'classes': 0.26; 'tried': 0.27; 'work.': 0.28; 'cc:addr:python.org': 0.29; 'hash': 0.30; "it'd": 0.30; 'chris': 0.30; 'subject:?': 0.31; 'implement': 0.32; 'header :User-Agent:1': 0.33; 'rather': 0.33; 'probably': 0.34; 'surprised': 0.34; 'things,': 0.37; 'but': 0.37; 'reasons': 0.37; 'useful': 0.38; 'correctly': 0.39; "couldn't": 0.39; 'define': 0.39; 'might': 0.40; 'addressing': 0.67; 'comply': 0.67; 'perspective,': 0.84; 'technically': 0.93 Date: Sun, 04 Dec 2011 12:57:50 -0600 From: Tim Chase User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16 MIME-Version: 1.0 To: Chris Angelico Subject: Re: order independent hash? X-Priority: 4 (Low) References: <30715729.411.1322753732534.JavaMail.geo-discussion-forums@pret21> <4ED7A2CE.6070306@davea.name> <6366868.86.1322800180523.JavaMail.geo-discussion-forums@pret21> <87k46fb8pg.fsf@xemacs.org> <87aa78bfvv.fsf@xemacs.org> In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323025080 news.xs4all.nl 6908 [2001:888:2000:d::a6]:49220 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16624 On 12/04/11 08:08, Chris Angelico wrote: > 2011/12/5 Hrvoje Niksic: >> If a Python >> implementation tried to implement dict as a tree, instances of classes >> that define only __eq__ and __hash__ would not be correctly inserted in >> such a dict. > > Couldn't you just make a tree of hash values? Okay, that's probably > not the most useful way to do things, but technically it'd comply with > the spec. From an interface perspective, I suppose it would work. However one of the main computer-science reasons for addressing by a hash is to get O(1) access to items (modulo pessimal hash structures/algorithms which can approach O(N) if everything hashes to the same value/bucket), rather than the O(logN) time you'd get from a tree. So folks reaching for a hash/map might be surprised if performance degraded with the size of the contents. -tkc