Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.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.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'operator': 0.03; 'modified': 0.05; 'subject:method': 0.09; 'subject:number': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'thread': 0.11; '255': 0.16; 'buggy': 0.16; 'non-trivial': 0.16; 'number?': 0.16; 'reason.': 0.16; 'silly': 0.16; 'storing': 0.16; 'subject:Converting': 0.16; 'string': 0.17; 'bytes': 0.17; 'code.': 0.20; 'to:name:python-list@python.org': 0.20; 'are.': 0.22; 'ticket': 0.24; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'actual': 0.28; 'hash': 0.29; 'improves': 0.29; 'perl': 0.29; 'remotely': 0.29; 'case,': 0.29; 'probably': 0.29; "i'm": 0.29; 'code': 0.31; '(and': 0.32; 'could': 0.32; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'so,': 0.35; 'there': 0.35; 'really': 0.36; 'characters': 0.36; 'limitation': 0.36; 'received:71': 0.36; "wasn't": 0.36; "didn't": 0.36; 'charset:us-ascii': 0.36; 'enough': 0.36; 'bad': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'received:10': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'your': 0.60; 'range': 0.60; 'matter': 0.61; 'back': 0.62; 'within': 0.64; 'limit': 0.65; 'results': 0.65; '10000': 0.65; 'treat': 0.65; 'potentially': 0.66; 'increase': 0.72; 'actually,': 0.84; 'collision': 0.84; "else's": 0.84; 'hardly': 0.84; 'lottery': 0.84; 'technically': 0.91; 'safe.': 0.93 From: "Leonard, Arah" To: "python-list@python.org" Subject: RE: Converting a string to a number by using INT (no hash method) Thread-Topic: Converting a string to a number by using INT (no hash method) Thread-Index: AQHN+M+MYr2tqWSCJEWWm4AMJlVPbJhWGp0A//+tRzA= Date: Tue, 22 Jan 2013 20:30:23 +0000 References: <4339f8d7-2d78-450f-ad0e-91da35615e6d@googlegroups.com> <2de57cf7-4a8f-4304-91cf-0024963315d7@googlegroups.com> <50FEE39E.4060204@davea.name> In-Reply-To: <50FEE39E.4060204@davea.name> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.73.1.96] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 22 Jan 2013 20:30:24.0442 (UTC) FILETIME=[4EA4A1A0:01CDF8DF] X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358886627 news.xs4all.nl 6890 [2001:888:2000:d::a6]:50235 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37345 > The perl code will produce the same hash for "abc.html" as for "bca.html= " That's probably one reason Leonard didn't try to transliterate the buggy= code. >=20 Actually, to give credit where it's due, it wasn't me. I just modified som= eone else's interesting solution in this thread and added the silly limit o= f 10000 to it. > In any case, the likelihood of a hash collision for any non-trivial websi= te is substantial. >=20 Exactly. Four digits is hardly enough range for it to be even remotely saf= e. And even then range isn't really the issue as technically it just impro= ves your odds. The results of a modulus operator are still non-unique no matter how many d= igits are there to work with ... within reason. Statistically anyone who b= uys a ticket could potentially win the lottery no matter how bad the odds a= re. ;) And now back to the OP, I'm still confused on this four-digit limitation. = Why isn't the limitation at least adhering to a bytelength like byte/short/= long? Is this database storing a string of characters instead of an actual= number? (And if so, then why not just block out 255 characters instead of= 4 to store a whole path? Or at the very least treat 4 characters as 4 byt= es to greatly increase the numeric range?)