Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'type,': 0.07; 'python': 0.08; 'deletion': 0.09; 'etc).': 0.09; 'historic': 0.09; 'size)': 0.09; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; '"python': 0.15; '(key,': 0.16; 'dictionary:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instance;': 0.16; 'sha,': 0.16; 'subject:independent': 0.16; 'transmit': 0.16; 'uncompressed': 0.16; 'wrote:': 0.18; 'memory': 0.21; 'mechanism': 0.21; 'result.': 0.21; 'input': 0.22; 'dec': 0.22; 'header:In-Reply- To:1': 0.22; '(usually': 0.23; 'archiving': 0.23; 'pair': 0.23; 'defined': 0.24; 'string': 0.24; 'message-id:@mail.gmail.com': 0.28; 'fixed': 0.29; 'pm,': 0.29; 'calculated': 0.30; 'hash': 0.30; 'value)': 0.30; 'usually': 0.31; 'subject:?': 0.31; "isn't": 0.33; 'object': 0.33; 'fri,': 0.34; 'done': 0.34; 'to:addr:python- list': 0.34; 'normally': 0.34; 'too': 0.34; 'algorithms': 0.34; 'operations': 0.35; 'uses': 0.36; 'but': 0.37; 'run': 0.37; 'received:google.com': 0.37; 'think': 0.37; 'steven': 0.38; 'received:209.85': 0.38; 'programming.': 0.39; 'tables': 0.39; "it's": 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'management': 0.60; '2011': 0.61; 'grow': 0.62; 'auto': 0.63; 'protection': 0.67; 'collection': 0.69; 'concept': 0.74; 'verification': 0.78; 'inquiring': 0.84; 'cryptography': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=ze4PJXRn0yIVzwuxVL2RUGwWVbS62hRrQPxIawhAE+0=; b=i4lAvpH5jDVS0Y1ZpnMXi2Gw8ZxrUGymqF60z7PvpTAuF0XO2ErhFmzLtEXtwPyUk7 9a6Nhd7P7VwBhcy2T043+hCkKEhApECrM6R8e8GImOtd8yVjDg8hSZQR/ofbLjw73z0i vukAHZc8iRUQkiiP3DCJ8PJSUhTXiqAdgEHCw= MIME-Version: 1.0 In-Reply-To: <6366868.86.1322800180523.JavaMail.geo-discussion-forums@pret21> References: <30715729.411.1322753732534.JavaMail.geo-discussion-forums@pret21> <4ED7A2CE.6070306@davea.name> <6366868.86.1322800180523.JavaMail.geo-discussion-forums@pret21> Date: Fri, 2 Dec 2011 16:00:10 +1100 Subject: Re: order independent hash? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1322802013 news.xs4all.nl 6882 [2001:888:2000:d::a6]:57306 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16526 On Fri, Dec 2, 2011 at 3:29 PM, 88888 Dihedral wrote: > I clear my point a hash is a collection of (key, value) pairs that have > well defined methods and behavior to be used in programming. > > The basic operations of a hash normally includes the following: > > 1. insertion of a (key, value) pair =A0into the hash > 2. deletion of a (key, value) from the hash > 3. inquiring =A0a hash by a key to retrieve the value if the (key, value) > pair available in the hash. If no key matched, the hash will return > a not found result. > > 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-fixed= size of (k,v) pairs. That's a hash table - think of a Python dictionary: On Fri, Dec 2, 2011 at 3:33 PM, Steven D'Aprano wrote: > Python dicts are hash tables. Although strictly speaking, isn't that "Python dicts are implemented as hash tables in CPython"? Or is the hashtable implementation mandated? Anyway, near enough. Cryptography and data verification use hashing too (look at the various historic hashing algorithms - CRC, MD5, SHA, etc). The concept of a hash is a number (usually of a fixed size) that is calculated from a string or other large data type, such that hashing the same input will always give the same output, but hashing different input will usually give different output. It's then possible to identify a large object solely by its hash, as is done in git, for instance; or to transmit both the data and the hash, as is done in message protection schemes (many archiving programs/formats include a hash of the uncompressed data). These have nothing to do with (key,value) pairs, but are important uses of hashes. ChrisA