Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Peter Otten
Adam Funk wrote: > On 2014-05-22, Chris Angelico wrote: > >> On Thu, May 22, 2014 at 11:54 PM, Adam Funk wrote: > >>> That ties in with a related question I've been wondering about lately >>> (using MD5s & SHAs for other things) --- getting a hash value (which >>> is internally numeric, rather

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Chris Angelico
On Fri, May 23, 2014 at 12:47 AM, Adam Funk 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, n

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Adam Funk
On 2014-05-22, Chris Angelico wrote: > On Thu, May 22, 2014 at 11:54 PM, Adam Funk wrote: >> That ties in with a related question I've been wondering about lately >> (using MD5s & SHAs for other things) --- getting a hash value (which >> is internally numeric, rather than string, right?) out as

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Adam Funk
On 2014-05-22, Chris Angelico wrote: > On Thu, May 22, 2014 at 11:41 PM, Adam Funk wrote: >> On further reflection, I think I asked for that. In fact, the table >> I'm using only has one column for the hashes --- I wasn't going to >> store the strings at all in order to save disk space (maybe my

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread alister
On Thu, 22 May 2014 12:47:31 +0100, Adam Funk wrote: > I'm using Python 3.3 and the sqlite3 module in the standard library. I'm > processing a lot of strings from input files (among other things, values > of headers in e-mail & news messages) and suppressing duplicates using a > table of seen stri

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Chris Angelico
On Thu, May 22, 2014 at 11:54 PM, Adam Funk wrote: >> >>> from hashlib import sha1 >> >>> s = "Hello world" >> >>> h = sha1(s) >> >>> h.hexdigest() >> '7b502c3a1f48c8609ae212cdfb639dee39673f5e' >> >>> int(h.hexdigest(), 16) >> 703993777145756967576188115661016000849227759454L > > That tie

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Chris Angelico
On Thu, May 22, 2014 at 11:41 PM, Adam Funk wrote: > On further reflection, I think I asked for that. In fact, the table > I'm using only has one column for the hashes --- I wasn't going to > store the strings at all in order to save disk space (maybe my mind is > stuck in the 1980s). That's a p

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Adam Funk
On 2014-05-22, Tim Chase wrote: > On 2014-05-22 12:47, Adam Funk wrote: >> I'm using Python 3.3 and the sqlite3 module in the standard library. >> I'm processing a lot of strings from input files (among other >> things, values of headers in e-mail & news messages) and suppressing >> duplicates usi

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Adam Funk
On 2014-05-22, Chris Angelico wrote: > On Thu, May 22, 2014 at 9:47 PM, Adam Funk wrote: >> I'm using Python 3.3 and the sqlite3 module in the standard library. >> I'm processing a lot of strings from input files (among other things, >> values of headers in e-mail & news messages) and suppressing

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Adam Funk
On 2014-05-22, Peter Otten wrote: > Adam Funk wrote: > >> I'm using Python 3.3 and the sqlite3 module in the standard library. >> I'm processing a lot of strings from input files (among other things, >> values of headers in e-mail & news messages) and suppressing >> duplicates using a table of see

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Tim Chase
On 2014-05-22 12:47, Adam Funk wrote: > I'm using Python 3.3 and the sqlite3 module in the standard library. > I'm processing a lot of strings from input files (among other > things, values of headers in e-mail & news messages) and suppressing > duplicates using a table of seen strings in the datab

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Chris Angelico
On Thu, May 22, 2014 at 9:47 PM, Adam Funk wrote: > I'm using Python 3.3 and the sqlite3 module in the standard library. > I'm processing a lot of strings from input files (among other things, > values of headers in e-mail & news messages) and suppressing > duplicates using a table of seen strings

Re: hashing strings to integers for sqlite3 keys

2014-05-22 Thread Peter Otten
Adam Funk wrote: > I'm using Python 3.3 and the sqlite3 module in the standard library. > I'm processing a lot of strings from input files (among other things, > values of headers in e-mail & news messages) and suppressing > duplicates using a table of seen strings in the database. > > It seems t