fast, large-width, non-cryptographic string hashing in python

后端 未结 5 1027
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 02:40

I have a need for a high-performance string hashing function in python that produces integers with at least 34 bits of output (64 bits would make sense, but

5条回答
  •  执念已碎
    2020-12-08 03:15

    "strings": I'm presuming you wish to hash Python 2.x str objects and/or Python3.x bytes and/or bytearray objects.

    This may violate your first constraint, but: consider using something like

    (zlib.adler32(strg, perturber) << N) ^ hash(strg)
    

    to get a (32+N)-bit hash.

提交回复
热议问题