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


Groups > comp.lang.python > #71898

Re: hashing strings to integers for sqlite3 keys

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'resulting': 0.04; 'memory.': 0.07; 'string': 0.09; 'arrays': 0.09; 'bytes.': 0.09; 'strings.': 0.09; 'subject:keys': 0.09; 'cc:addr:python-list': 0.11; '23,': 0.16; 'adam': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'functions;': 0.16; 'hashes': 0.16; 'integer.': 0.16; "languages'": 0.16; 'sorts': 0.16; 'subject:sqlite3': 0.16; 'followed': 0.16; 'language': 0.16; 'wrote:': 0.18; 'things.': 0.19; 'cc:addr:python.org': 0.22; 'byte': 0.24; 'bytes': 0.24; 'interpret': 0.24; 'module,': 0.24; 'string,': 0.24; 'cc:2**0': 0.24; 'least': 0.26; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'characters': 0.30; 'message- id:@mail.gmail.com': 0.30; 'along': 0.30; 'usually': 0.31; 'struct': 0.31; 'probably': 0.32; 'fri,': 0.33; 'maybe': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'sequence': 0.36; 'done': 0.36; 'how': 0.40; 'easy': 0.60; 'number,': 0.60; 'designers': 0.74; 'you;': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=vQIPsEVDSgtierRTZPjWZdhy9K9SzoDx2RSzt25dBYI=; b=FG/J09y/4J5LFNNP2FWdUu5kaLXefoVszoBHVWAEU2Zs7xbb/K/d1l8pRVHIsnETIS qrzuPlq/Uwi9rllxgBnfm0b2e5xo5kdMQaFqw0Hsr4b2nyYnx1XlY8F5hCjBA4rJH4MT VOFsHe17JgWRoRQNHhUU+JoEvUzx1AvXkBUAaQ5YvOqyVzLX2k5I7K/+zpPmPEmFkHoB f3k2r87v9ywP0FPPgNbnRbYeyMG2r0Z8e4BfexLZnVDSdT51z5RETzluJ/pdM3Sy6gWj Qpo1rn8QS6DI8PSiwjuNedt4qvwCUTU80NnBZc4VDfMfMJdT3s4+jbAaEuf4OjQshalr tZhQ==
MIME-Version 1.0
X-Received by 10.220.133.197 with SMTP id g5mr16403650vct.20.1400771370654; Thu, 22 May 2014 08:09:30 -0700 (PDT)
In-Reply-To <k9f15bxoql.ln2@news.ducksburg.com>
References <jn415bx6uf.ln2@news.ducksburg.com> <mailman.10220.1400764235.18130.python-list@python.org> <05c15bxrpj.ln2@news.ducksburg.com> <mailman.10223.1400768058.18130.python-list@python.org> <k9f15bxoql.ln2@news.ducksburg.com>
Date Fri, 23 May 2014 01:09:30 +1000
Subject Re: hashing strings to integers for sqlite3 keys
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.10224.1400771378.18130.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1400771378 news.xs4all.nl 2961 [2001:888:2000:d::a6]:46563
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:71898

Show key headers only | View raw


On Fri, May 23, 2014 at 12:47 AM, Adam Funk <a24061@ducksburg.com> wrote:
>> I don't know that there is, at least not with hashlib. You might be
>> able to use digest() followed by the struct module, but it's no less
>> convoluted. It's the same in several other languages' hashing
>> functions; the result is a string, not an integer.
>
> Well, J*v* returns a byte array...

I counted byte arrays along with strings. Whether it's notionally a
string of bytes or characters makes no difference - it's not an
integer.

> I dunno why language designers don't make it easy to get a single big
> number directly out of these things.

It's probably because these sorts of hashes are usually done on large
puddles of memory, to create a smaller puddle of memory. How you
interpret the resulting puddle is up to you; maybe you want to think
of it as a number, maybe as a string, but really it's just a sequence
of bytes.

ChrisA

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


Thread

hashing strings to integers for sqlite3 keys Adam Funk <a24061@ducksburg.com> - 2014-05-22 12:47 +0100
  Re: hashing strings to integers for sqlite3 keys Peter Otten <__peter__@web.de> - 2014-05-22 14:58 +0200
    Re: hashing strings to integers for sqlite3 keys Adam Funk <a24061@ducksburg.com> - 2014-05-22 14:41 +0100
      Re: hashing strings to integers for sqlite3 keys Chris Angelico <rosuav@gmail.com> - 2014-05-23 00:08 +1000
        Re: hashing strings to integers for sqlite3 keys Adam Funk <a24061@ducksburg.com> - 2014-05-22 15:40 +0100
  Re: hashing strings to integers for sqlite3 keys Chris Angelico <rosuav@gmail.com> - 2014-05-22 23:03 +1000
    Re: hashing strings to integers for sqlite3 keys Adam Funk <a24061@ducksburg.com> - 2014-05-22 14:47 +0100
  Re: hashing strings to integers for sqlite3 keys Tim Chase <python.list@tim.thechases.com> - 2014-05-22 08:09 -0500
    Re: hashing strings to integers for sqlite3 keys Adam Funk <a24061@ducksburg.com> - 2014-05-22 14:54 +0100
      Re: hashing strings to integers for sqlite3 keys Chris Angelico <rosuav@gmail.com> - 2014-05-23 00:14 +1000
        Re: hashing strings to integers for sqlite3 keys Adam Funk <a24061@ducksburg.com> - 2014-05-22 15:47 +0100
          Re: hashing strings to integers for sqlite3 keys Chris Angelico <rosuav@gmail.com> - 2014-05-23 01:09 +1000
          Re: hashing strings to integers for sqlite3 keys Peter Otten <__peter__@web.de> - 2014-05-22 17:34 +0200
            hashing strings to integers (was: hashing strings to integers for sqlite3 keys) Adam Funk <a24061@ducksburg.com> - 2014-05-23 11:27 +0100
              Re: hashing strings to integers Adam Funk <a24061@ducksburg.com> - 2014-05-23 11:36 +0100
                Re: hashing strings to integers Chris Angelico <rosuav@gmail.com> - 2014-05-23 21:01 +1000
              Re: hashing strings to integers (was: hashing strings to integers for sqlite3 keys) Chris Angelico <rosuav@gmail.com> - 2014-05-23 20:59 +1000
                Re: hashing strings to integers Adam Funk <a24061@ducksburg.com> - 2014-05-27 16:13 +0100
                Re: hashing strings to integers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-27 17:02 +0000
                Re: hashing strings to integers Chris Angelico <rosuav@gmail.com> - 2014-05-28 05:16 +1000
                Re: hashing strings to integers Dan Sommers <dan@tombstonezero.net> - 2014-05-28 01:55 +0000
                Re: hashing strings to integers Adam Funk <a24061@ducksburg.com> - 2014-06-03 11:29 +0100
                Re: hashing strings to integers Adam Funk <a24061@ducksburg.com> - 2014-06-03 11:32 +0100
              Re: hashing strings to integers Terry Reedy <tjreedy@udel.edu> - 2014-05-23 15:10 -0400
                Re: hashing strings to integers Adam Funk <a24061@ducksburg.com> - 2014-05-27 16:20 +0100
  Re: hashing strings to integers for sqlite3 keys alister <alister.nospam.ware@ntlworld.com> - 2014-05-22 14:48 +0000

csiph-web