Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37347

Re: Converting a string to a number by using INT (no hash method)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
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; 'alan': 0.09; 'errors,': 0.09; '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; 'earlier.': 0.16; 'md5': 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; 'wrote:': 0.17; 'bytes': 0.17; 'module,': 0.17; 'code.': 0.20; 'trying': 0.21; 'are.': 0.22; 'programming': 0.23; 'ticket': 0.24; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'expand': 0.26; "doesn't": 0.28; 'actual': 0.28; 'noticed': 0.28; 'hash': 0.29; 'improves': 0.29; 'perl': 0.29; 'remotely': 0.29; "who'd": 0.29; 'case,': 0.29; 'probably': 0.29; "i'm": 0.29; 'that.': 0.30; 'code': 0.31; '(and': 0.32; 'anybody': 0.32; 'could': 0.32; 'him.': 0.33; 'programming,': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'done': 0.34; 'thanks': 0.34; 'so,': 0.35; 'pm,': 0.35; 'there': 0.35; 'really': 0.36; 'characters': 0.36; 'limitation': 0.36; "wasn't": 0.36; "didn't": 0.36; 'anything': 0.36; "i'll": 0.36; 'enough': 0.36; 'bad': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'fact': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'your': 0.60; 'valuable': 0.60; 'range': 0.60; 'matter': 0.61; 'back': 0.62; 'worth': 0.63; 'information': 0.63; 'within': 0.64; 'our': 0.65; 'gave': 0.65; 'limit': 0.65; 'results': 0.65; '10000': 0.65; 'hints': 0.65; 'treat': 0.65; 'potentially': 0.66; 'wish': 0.70; 'internet': 0.71; 'received:74.208': 0.71; 'increase': 0.72; 'actually,': 0.84; 'collision': 0.84; "else's": 0.84; 'hardly': 0.84; 'lottery': 0.84; 'adopt': 0.91; 'technically': 0.91; 'safe.': 0.93
Date Tue, 22 Jan 2013 15:43:27 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: Converting a string to a number by using INT (no hash method)
References <e74ae1aa-f760-4123-8770-3b8a4f9a2f91@googlegroups.com> <mailman.806.1358872054.2939.python-list@python.org> <4339f8d7-2d78-450f-ad0e-91da35615e6d@googlegroups.com> <mailman.812.1358875475.2939.python-list@python.org> <2de57cf7-4a8f-4304-91cf-0024963315d7@googlegroups.com> <50FEE39E.4060204@davea.name> <2ECADBDABCB17E40B66A25D839706F5E075862B8@msnmail2.bruker-axs.com>
In-Reply-To <2ECADBDABCB17E40B66A25D839706F5E075862B8@msnmail2.bruker-axs.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:Ajev9ak+o22ai4cKEBTLSMiaW9Tdvb8OeVZiY2VhWuj fx486lPIHQ2BU3m/POvW049uZ+68R9sd5tIZSOnVAX8dr6jPHC iv7UYUMbHV75vP+JCAAVJVktv7w7kkaaMFf4Rgv5xkVODmv4I9 Yp3d6b18KtqCiRjhPyrzF0IGzEOlDoaB14Gg18jzRGCQQ00DdV Grz0Pez9ptF51UIWwjePCmXAsWwIl1WXZxRIX+XdXztmhaXGvt CKLCMP2AxIEZTx/E21998/ea/bXXJ/HfiFferu7yODQU1PHVur AqFXoih1okQ54Gn4k91wu66udU+8UTRQsVCcjp+SFFEG6Zo8Q= =
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.835.1358887428.2939.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358887428 news.xs4all.nl 6907 [2001:888:2000:d::a6]:56015
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37347

Show key headers only | View raw


On 01/22/2013 03:30 PM, Leonard, Arah wrote:
>> 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.
>>
>
> Actually, to give credit where it's due, it wasn't me.  I just modified someone else's interesting solution in this thread and added the silly limit of 10000 to it.
>

That's okay.  The OP doesn't seem to know anything about programming, or 
about information theory, so the fact you gave a single line that 
actually "works" must be extraordinarily valuable to him.  When he was 
trying to use the md5 module, I gave him the hints about his five 
programming errors, and was about to expand on it when i noticed his 4 
digit limitation.

>> In any case, the likelihood of a hash collision for any non-trivial website is substantial.
>>
>
> Exactly.  Four digits is hardly enough range for it to be even remotely safe.  And even then range isn't really the issue as technically it just improves your odds.
>
> The results of a modulus operator are still non-unique no matter how many digits are there to work with ... within reason.  Statistically anyone who buys a ticket could potentially win the lottery no matter how bad the odds are.  ;)
>
> 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 bytes to greatly increase the numeric range?)
>

I wish I had done the internet search earlier.  This name 'ferrous 
cranus' is a pseudonym of various trolls, and anybody who'd adopt it 
isn't worth our time.

Thanks to Alan Spence for spotting that.  I'll plonk 'ferrous cranus' now.


-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 08:15 -0800
  RE: Converting a string to a number by using INT  (no hash method) "Leonard, Arah" <Arah.Leonard@bruker-axs.com> - 2013-01-22 16:27 +0000
    Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 09:02 -0800
      RE: Converting a string to a number by using INT  (no hash method) "Leonard, Arah" <Arah.Leonard@bruker-axs.com> - 2013-01-22 17:24 +0000
        Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 09:39 -0800
          Re: Converting a string to a number by using INT (no hash method) John Gordon <gordon@panix.com> - 2013-01-22 18:36 +0000
          Re: Converting a string to a number by using INT  (no hash method) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-22 17:22 -0500
        Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 09:39 -0800
        Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 10:37 -0800
          Re: Converting a string to a number by using INT  (no hash method) Michael Torrie <torriem@gmail.com> - 2013-01-22 12:02 -0700
            Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 11:28 -0800
              Re: Converting a string to a number by using INT  (no hash method) Alan Spence <alan.spence@ntlworld.com> - 2013-01-22 20:00 +0000
            Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 11:28 -0800
              Re: Converting a string to a number by using INT (no hash method) John Gordon <gordon@panix.com> - 2013-01-22 20:40 +0000
                Re: Converting a string to a number by using INT (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-23 00:44 -0800
          Re: Converting a string to a number by using INT  (no hash method) Dave Angel <d@davea.name> - 2013-01-22 14:08 -0500
          RE: Converting a string to a number by using INT  (no hash method) "Leonard, Arah" <Arah.Leonard@bruker-axs.com> - 2013-01-22 20:30 +0000
          Re: Converting a string to a number by using INT  (no hash method) Dave Angel <d@davea.name> - 2013-01-22 15:43 -0500
        Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 10:37 -0800
    Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 09:02 -0800
  Re: Converting a string to a number by using INT  (no hash method) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-01-22 16:27 +0000
  Re: Converting a string to a number by using INT  (no hash method) Dave Angel <d@davea.name> - 2013-01-22 11:40 -0500
    Re: Converting a string to a number by using INT (no hash method) alex23 <wuwei23@gmail.com> - 2013-01-22 17:32 -0800
      Re: Converting a string to a number by using INT (no hash method) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-23 03:02 +0000
        Re: Converting a string to a number by using INT (no hash method) alex23 <wuwei23@gmail.com> - 2013-01-22 19:59 -0800
  Re: Converting a string to a number by using INT  (no hash method) "D'Arcy J.M. Cain" <darcy@druid.net> - 2013-01-22 12:04 -0500

csiph-web