Python: hash() yields different results for different platforms

  • dennis_lee_bieber / 200 / Fri, 27 Mar 2009 05:39:00 GMT / Comments (0)
  • On 11 Jul 2006 16:33:50 -0700, "Qiangning Hong" <hongqn...gmail.com>
    declaimed the following in comp.lang.python:

    > I believe this will be faster than making the "url" column unique key
    > and doing string comparation. Right?
    >

    Given that the queries pass the data as strings, you're trading an
    integer->string, string->integer conversion pair on each search,
    followed by an index file look-up, for a straight index file look-up.

    Granted, my college days were a quarter century ago, but at the
    time, the data structures class required implementing a hash table
    look-up program (hashed-head, multiple-linked list). Hashes weren't
    guaranteed to be unique -- the hash only gave an entry point from which
    one then performed string comparisons. *

    You could maybe use MD5 encoding if you don't want the pure URL in
    the look-up, and MySQL, at least, has a built-in for MD5 so you wouldn't
    even have to worry about "differences".

    * The Amiga file-system was a hashed-head, multiple-linked list -- the
    only place I'd ever encountered one outside of that 3rd year college
    course. File-names were hashed into an index into a directory block; the
    directory block had pointers to file-header/subdirectory blocks... those
    blocks then had a linked list to other fh/sd blocks that shared the hash
    value.
    --
    Wulfraed Dennis Lee Bieber KD6MOG
    wlfraed...ix.netcom.com wulfraed...bestiaria.com
    HTTP://wlfraed.home.netcom.com/
    (Bestiaria Support Staff: web-asst...bestiaria.com)
    HTTP://www.bestiaria.com/
  • Keywords:

    hash, yields, different, results, platforms, python

  • http://programming.itags.org/python/32375/«« Last Thread - Next Thread »»