python-farmhash icon indicating copy to clipboard operation
python-farmhash copied to clipboard

Support farmhash for bytes-like objects

Open jcdong98 opened this issue 1 year ago • 0 comments

In the current version,

  • farmhash does not support bytes in Python 3.
    For example, farmhash.hash64(b'123') will lead to TypeError: argument 1 must be str, not bytes.
  • It does not support strings containing embedded nulls as well.
    farmhash.hash64('\x00') will cause ValueError: embedded null character.

This PR enables the functionality to deal with bytes-like objects and strings containing embedded nulls. After this PR is merged, we can call farmhash functions as follows without error.

farmhash.hash64('abc')  # 2640714258260161385
farmhash.hash64(b'abc')  # 2640714258260161385
farmhash.hash64('\x00')  # 13718060045003475796
farmhash.hash64(b'\x00')  # 13718060045003475796

jcdong98 avatar May 02 '24 11:05 jcdong98