Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'though.': 0.07; 'python': 0.08; 'hash': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'cpython,': 0.16; 'dummy': 0.16; 'header:In-Reply-To:1': 0.21; 'fri,': 0.23; 'received:209.85.161.46': 0.23; 'received:mail- fx0-f46.google.com': 0.23; 'code': 0.24; 'values': 0.25; 'received:209.85.161': 0.26; "i'm": 0.27; 'message- id:@mail.gmail.com': 0.28; 'equal': 0.31; 'to:addr:python-list': 0.33; 'actually': 0.33; '(for': 0.33; 'question': 0.34; 'chris': 0.34; 'received:google.com': 0.37; 'received:209.85': 0.37; '20,': 0.37; 'checks': 0.37; 'think': 0.38; 'subject:: ': 0.38; 'received:209': 0.39; 'containing': 0.39; 'to:addr:python.org': 0.39; 'ever': 0.64; '10:36': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=hsQ0gStoV+USAkU00lz5aA768gGMk2PJjlriuW5sUxU=; b=GBNSrNC0GexEatX8p+VdJg1P0XK8Xc3eedzW5ALyeHmF41qofEDOzeJOokMnmiscf8 y4I0UGGOLKd5hnCGAJhEqLb6tF3jbS+kD6oEsQaqBC6UprOvJ+EbiRWQOtAAKRKxl4fl QT5RygZRvlspOJG956h9NMo+UGxkJuhnt2rZo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=YJ11OTNLxdpYqrRhhqbDHq+sipWFYbfEISbQrGBBxvRZt/od/OLbUzTmVQmfhmykOC TfN0JjZa16Kcoj4CIam8hl+s0MIDwhor5QttyqT+VF2HGhtfKFckKmv816hw9YPo3bh1 wbGP9bu3qHmYdB4T59dZgm0WN0cpf/PlhdvLU= MIME-Version: 1.0 In-Reply-To: References: <4DD2C2A5.3080403@stoneleaf.us> <4DD2D89D.4000303@stoneleaf.us> <4DD2F661.2050005@stoneleaf.us> <0deha8-6u9.ln1@satorlaser.homedns.org> <4DD68DAA.9050209@mrabarnett.plus.com> From: Ian Kelly Date: Fri, 20 May 2011 11:59:44 -0600 Subject: Re: hash values and equality To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 11 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305914417 news.xs4all.nl 49177 [::ffff:82.94.164.166]:49837 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5866 On Fri, May 20, 2011 at 10:36 AM, Chris Kaynor wrote: > I think the question was: can this dummy code ever produce a set containing > less then itemCount items (for 0 < itemCount < 2**32)? In CPython, no. Even when you get a hash collision, the code checks to see whether the hashes are actually equal before it calls the rich comparison, the former check being a much faster operation since the hash values are cached. I'm not sure whether this can be counted on for all Python implementations, though.