(k)
return int(c)
Old Postgres hashtext()
Old Postgres hashtext()
Old Postgres hashtext ()
def hashtext_old_py(k):
    """Old Postgres hashtext()"""

    remain = len(k)
    pos = 0
    a = b = 0x9e3779b9
    c = 3923095

    # handle most of the key
    while remain >= 12:
        a2, b2, c2 = FMT_OLD.unpack_from(k, pos)
        a, b, c = mix_old(a + a2, b + b2, c + c2)
        pos += 12;
        remain -= 12;

    # handle the last 11 bytes
    a2, b2, c2 = FMT_OLD.unpack_from(k[pos:] + PADDING, 0)

    # the lowest byte of c is reserved for the length
    c2 = (c2 << 8) + len(k)

    a, b, c = mix_old(a + a2, b + b2, c + c2)

    # convert to signed int
    if (c & 0x80000000):
        c = -0x100000000 + c

    return int(c)
def hashtext_old_py ( k ) : remain = len ( k ) pos = 0 a = b = 0x9e3779b9 c = 3923095 # handle most of the key while remain >= 12 : a2 , b2 , c2 = FMT_OLD . unpack_from ( k , pos ) a , b , c = mix_old ( a + a2 , b + b2 , c + c2 ) pos += 12 remain -= 12 # handle the last 11 bytes a2 , b2 , c2 = FMT_OLD . unpack_from ( k [ pos : ] + PADDING , 0 ) # the lowest byte of c is reserved for the length c2 = ( c2 << 8 ) + len ( k ) a , b , c = mix_old ( a + a2 , b + b2 , c + c2 ) # convert to signed int if ( c & 0x80000000 ) : c = - 0x100000000 + c return int ( c )