Skip to content

Commit

Permalink
Modify hash_func example
Browse files Browse the repository at this point in the history
  • Loading branch information
KenanHanke committed Oct 1, 2024
1 parent 3252b76 commit 43e8c20
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,12 @@ to use the following example in your own code:
from rbloom import Bloom
from hashlib import sha256
from pickle import dumps
from sys import byteorder

def hash_func(obj):
h = sha256(dumps(obj)).digest()
return int.from_bytes(h[:16], byteorder, signed=True)
# use sys.byteorder instead of "big" for a small speedup when
# reproducibility across different machines isn't a concern
return int.from_bytes(h[:16], "big", signed=True)

bf = Bloom(100_000_000, 0.01, hash_func)
```
Expand Down

0 comments on commit 43e8c20

Please sign in to comment.