Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'value,': 0.04; 'pointer': 0.05; 'correct.': 0.09; 'from:addr:python': 0.09; 'hash': 0.09; 'integer,': 0.09; 'slot': 0.09; 'described': 0.14; 'wrote:': 0.14; '(is': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr:python-list': 0.16; 'header:In-Reply-To:1': 0.21; 'memory': 0.22; 'objects': 0.23; "doesn't": 0.25; 'index': 0.25; 'received:84': 0.25; 'stored': 0.25; 'object': 0.26; 'elements': 0.29; "python's": 0.29; 'array': 0.30; 'table.': 0.30; 'looks': 0.31; 'equal': 0.31; 'usage': 0.32; 'filled': 0.32; 'to:addr:python-list': 0.33; 'it?': 0.33; 'header :User-Agent:1': 0.35; 'reply-to:addr:python.org': 0.35; 'table': 0.37; 'brief': 0.37; 'think': 0.38; 'could': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'christian': 0.39; 'to:addr:python.org': 0.39; 'your': 0.60; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72; 'schrieb': 0.84; 'spell': 0.91 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlIGAHfL1k1UXebj/2dsb2JhbACYI418eMJWhhkElECKRw Date: Fri, 20 May 2011 21:17:29 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: python-list@python.org Subject: Re: hash values and equality References: <4DD2C2A5.3080403@stoneleaf.us> <4DD2D89D.4000303@stoneleaf.us> <4DD2F661.2050005@stoneleaf.us> <0deha8-6u9.ln1@satorlaser.homedns.org> <4DD68DAA.9050209@mrabarnett.plus.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org 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: 18 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305922657 news.xs4all.nl 49039 [::ffff:82.94.164.166]:46067 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5878 On 20/05/2011 20:01, Christian Heimes wrote: > Am 20.05.2011 17:50, schrieb MRAB: >> Is this strictly true? I thought that the hash value, an integer, is >> moduloed (Is that how you spell it? Looks weird!) with the number of >> array elements to give an index into the array, so different hashes >> could give the same index, and objects with different hashes could be >> stored in the same 'bucket'. > > I don't think 'moduloed' is an existing word but your description is > mostly correct. The hash of the object and length of the hash table are > used to calculate the position in the hash table. However Python's > implementation doesn't use buckets to reduce memory usage and pointer > dereferencing. If a slot in the hash table is already filled with an > object that is not equal to the new object (a collision), the hash is > shifted and the new slot is checked. The implementation detail is well > described in Modules/dictobject.c. > A brief search on the web found a use of the word in 1982.