Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16640
| 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 | <drsalists@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.119 |
| X-Spam-Level | * |
| X-Spam-Evidence | '*H*': 0.76; '*S*': 0.00; 'args': 0.05; 'ideas?': 0.16; 'integers.': 0.16; 'subject:independent': 0.16; 'cc:addr :python-list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'command': 0.24; 'url:mailman': 0.28; 'needed,': 0.28; 'sound': 0.28; 'message-id:@mail.gmail.com': 0.28; 'elements': 0.29; 'mapping': 0.29; 'cc:addr:python.org': 0.29; 'hash': 0.30; 'received:mail-bw0-f46.google.com': 0.30; 'subject:?': 0.31; 'go.': 0.32; 'list': 0.32; 'received:209.85.214': 0.32; 'url:listinfo': 0.32; 'sort': 0.33; "won't": 0.33; 'things': 0.34; 'operations': 0.35; 'url:python': 0.36; 'members': 0.37; 'two': 0.37; 'but': 0.37; 'list,': 0.37; 'received:google.com': 0.37; 'could': 0.37; 'bunch': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'url:org': 0.39; "it's": 0.40; 'received:209': 0.40; 'might': 0.40; 'once': 0.60; 'more': 0.61; 'your': 0.61; 'order': 0.62; 'life': 0.64; 'methods:': 0.67; 'often,': 0.84; 'scatter': 0.84; 'fast,': 0.91; 'sum.': 0.91 |
| 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 :cc:content-type; bh=WDJ/Ux2fov/KxIUAUtJjzDZVtkSGL7+RFSq16T/vgEo=; b=SlZpqbdhQjMCJcI2sgVeWVAxSn5XLdkosWS4fgpxRlFZjC9oCCdayY3z0scXNb5FMB Ez68bbcb0hTFxtzSz2HtOxrV/4WN/SQ99VwUd9rdkjuftcJoTHRD6fxb7K3Vji6wnqua GNJLuV2YHeFqXeEjTq0rQd5ecnOD/OVmUSVjA= |
| MIME-Version | 1.0 |
| In-Reply-To | <jb57p7$b1j$1@dough.gmane.org> |
| References | <jb57p7$b1j$1@dough.gmane.org> |
| Date | Sun, 4 Dec 2011 21:50:08 -0800 |
| Subject | Re: order independent hash? |
| From | Dan Stromberg <drsalists@gmail.com> |
| To | Neal Becker <ndbecker2@gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3287.1323064211.27778.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1323064211 news.xs4all.nl 6957 [2001:888:2000:d::a6]:38660 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:16640 |
Show key headers only | View raw
Two methods: 1) If you need your hash only once in an infrequent while, then save the elements in a list, appending as needed, and sort prior to hashing, as needed 2) If you need your hash more often, you could keep your elements in a treap or red-black tree; these will maintain sortedness throughout the life of the datastructure. 3) If A bunch of log(n) or n or nlog(n) operations doesn't sound appealing, then you might try this one: Create some sort of mapping from your elements to the integers. Then just use a sum. This won't scatter things nearly as well as a cryptographic hash, but it's very fast, because you don't need to reevaluate some of your members as you go. HTH On 11/30/11, Neal Becker <ndbecker2@gmail.com> wrote: > I like to hash a list of words (actually, the command line args of my > program) > in such a way that different words will create different hash, but not > sensitive > to the order of the words. Any ideas? > > -- > http://mail.python.org/mailman/listinfo/python-list >
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: order independent hash? Dan Stromberg <drsalists@gmail.com> - 2011-12-04 21:50 -0800
Re: order independent hash? 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-05 04:09 -0800
Re: order independent hash? 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-05 04:09 -0800
Re: order independent hash? Dan Stromberg <drsalists@gmail.com> - 2011-12-05 15:05 -0800
csiph-web