Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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; 'received:verizon.net': 0.07; 'terry': 0.07; 'contexts': 0.09; 'dict': 0.09; 'mutable': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'am,': 0.12; '"python': 0.15; 'additions': 0.16; 'deletions': 0.16; 'does,': 0.16; 'hashable': 0.16; 'reedy': 0.16; 'subject:independent': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'perl': 0.18; 'purposes,': 0.18; 'jan': 0.19; 'memory': 0.21; 'mechanism': 0.21; 'header:In- Reply-To:1': 0.22; 'table.': 0.23; 'tree': 0.25; 'writes:': 0.25; 'structure': 0.26; '(this': 0.28; 'mapping': 0.29; 'seem': 0.30; 'hash': 0.30; 'protocol.': 0.30; '\xe2\x80\x94': 0.30; 'chris': 0.30; 'equivalent': 0.31; 'subject:?': 0.31; 'does': 0.32; 'values': 0.32; 'programmers': 0.32; 'pretty': 0.32; "isn't": 0.33; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'instead': 0.33; 'there': 0.33; 'object': 0.33; 'to:addr :python-list': 0.34; 'especially': 0.35; 'but': 0.37; 'run': 0.37; 'could': 0.37; 'maps': 0.38; 'received:org': 0.38; 'tables': 0.39; 'called': 0.40; "it's": 0.40; 'to:addr:python.org': 0.40; 'management': 0.60; 'types': 0.61; 'grow': 0.62; 'auto': 0.63 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: order independent hash? Date: Fri, 02 Dec 2011 16:40:24 -0500 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <87k46fb8pg.fsf@xemacs.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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1322862043 news.xs4all.nl 6904 [2001:888:2000:d::a6]:47937 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16572 On 12/2/2011 4:53 AM, Hrvoje Niksic wrote: > Chris Angelico writes: > >>> The hash can grow with (k,v) pairs accumulated in the run time. >>> An auto memory management mechanism is required for a hash of a non-f= ixed size of (k,v) pairs. >> >> That's a hash table > > In many contexts "hash table" is shortened to "hash" when there is no > ambiguity. This is especially popular among Perl programmers where the= > equivalent of dict is called a hash. > >> Although strictly speaking, isn't that "Python dicts are implemented >> as hash tables in CPython"? Or is the hashtable implementation >> mandated? > > It's pretty much mandated because of the __hash__ protocol. Lib Ref 4.8. Mapping Types =E2=80=94 dict "A mapping object maps hashable values to arbitrary objects." This does not say that the mapping has to *use* the hash value ;-). Even if it does, it could use a tree structure instead of a hash table.=20 But hash tables seem to work well for general purposes, "Mappings are mutable objects." (This would change if a frozendict were added.) especially when additions and deletions are needed. --=20 Terry Jan Reedy