Skip to content

Commit

Permalink
minor improvments to default hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
barrust committed Mar 20, 2020
1 parent 412637e commit a71ce86
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# PyProbables Changelog

### Version 0.3.1
* Add additional __slots__
* Very minor improvement to the hashing algorithm

### Version 0.3.0
* Bloom Filters:
* Import/Export of Expanding and Rotating Bloom Filters
Expand Down
2 changes: 1 addition & 1 deletion probables/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
__maintainer__ = 'Tyler Barrus'
__email__ = '[email protected]'
__license__ = 'MIT'
__version__ = '0.3.0'
__version__ = '0.3.1'
__credits__ = []
__url__ = 'https://github.com/barrust/pyprobables'
__bugtrack_url__ = 'https://github.com/barrust/pyprobables/issues'
Expand Down
18 changes: 9 additions & 9 deletions probables/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ def hash_with_depth_int(func):
def hashing_func(key, depth=1):
''' wrapper function '''
res = list()
tmp = key
for _ in range(depth):
if tmp != key:
tmp = func("{0:x}".format(tmp))
else:
tmp = func(key)
tmp = func(key)
res.append(tmp)
for _ in range(depth - 1):
tmp = func("{0:x}".format(tmp))
res.append(tmp)
return res
return hashing_func
Expand Down Expand Up @@ -83,9 +81,11 @@ def fnv_1a(key):
max64mod = UINT64_T_MAX + 1
hval = 14695981039346656073
fnv_64_prime = 1099511628211
for t_str in key:
hval = hval ^ ord(t_str)
hval = (hval * fnv_64_prime) % max64mod
tmp = map(ord, key)
for t_str in tmp:
hval ^= t_str
hval *= fnv_64_prime
hval %= max64mod
return hval


Expand Down

0 comments on commit a71ce86

Please sign in to comment.