Types for pyfarmhash

raw JSON →
0.4.0.20260408 verified Mon Apr 27 auth: no python

Typing stubs for pyfarmhash, provided by typeshed. Currently at version 0.4.0.20260408, updated regularly alongside typeshed releases. These stubs enable type-checking for the pyfarmhash library, which provides farmhash hash functions. Requires Python >=3.10.

pip install types-pyfarmhash
error ImportError: No module named 'pyfarmhash'
cause pyfarmhash itself is not installed; only the stubs are installed.
fix
Install the runtime library: pip install pyfarmhash
error TypeError: expected bytes, not str
cause Passing a string without encoding when bytes is expected.
fix
Use b'str' or my_str.encode()
gotcha The seed parameter must be provided as a keyword argument for some functions.
fix Always pass seed as keyword: pyfarmhash.hash64(b'data', seed=0)
gotcha Input types must be bytes or str for hash functions. Passing integers or other types will raise TypeError.
fix Ensure input is bytes: pyfarmhash.hash64(b'123') vs hash64(123).

Basic usage of pyfarmhash with type stub support.

import pyfarmhash

# hash64 with bytes or string seed
result = pyfarmhash.hash64(b"hello", seed=123)
print(result)

# hash64 with string seed (encoded in C)
result = pyfarmhash.hash64("hello", seed=456)
print(result)