Skip to content

Commit 7e62582

Browse files
authored
Merge pull request #4 from joseph-fox/fix-overflow-error
Replace xrange by count
2 parents 2a162f9 + e204ebc commit 7e62582

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Changes in 2.2
2+
==============
3+
Replaced the xrange by count, so it is a iterator now.
4+
This fixes overflow error when a large integer is passed
5+
the range_fun.
6+
17
Changes in 2.1
28
==============
39
The tightening ratio is 0.9, and it is consistently used.

pybloom_live/pybloom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def make_hashfuncs(num_slices, num_bits):
7474
num_salts, extra = divmod(num_slices, len(fmt))
7575
if extra:
7676
num_salts += 1
77-
salts = tuple(hashfn(hashfn(pack('I', i)).digest()) for i in range_fn(num_salts))
77+
salts = tuple(hashfn(hashfn(pack('I', i)).digest()) for i in range_fn(0, num_salts))
7878

7979
def _make_hashfuncs(key):
8080
if running_python_3:

pybloom_live/test_pybloom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _run():
8282

8383
class Serialization(unittest.TestCase):
8484
SIZE = 12345
85-
EXPECTED = set([random.randint(0, 10000100) for _ in range_fn(SIZE)])
85+
EXPECTED = set([random.randint(0, 10000100) for _ in range_fn(0, SIZE)])
8686

8787
def test_serialization(self):
8888
for klass, args in [(BloomFilter, (self.SIZE,)),

pybloom_live/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import sys
2+
import itertools
3+
24
try:
35
import StringIO
46
import cStringIO
@@ -8,11 +10,11 @@
810
running_python_3 = sys.version_info[0] == 3
911

1012

11-
def range_fn(*args):
13+
def range_fn(start=0, stop=None):
1214
if running_python_3:
13-
return range(*args)
15+
return range(start, stop)
1416
else:
15-
return xrange(*args)
17+
return iter(itertools.count(start).next, stop)
1618

1719

1820
def is_string_io(instance):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
from setuptools import setup
33

4-
VERSION = '2.1.0'
4+
VERSION = '2.2.0'
55
DESCRIPTION = "Bloom filter: A Probabilistic data structure"
66
LONG_DESCRIPTION = """
77
This bloom filter is forked from pybloom, and its tightening ratio is changed to 0.9, and this ration is consistently used. Choosing r around 0.8 - 0.9 will result in better average space usage for wide range of growth, therefore the default value of model is set to LARGE_SET_GROWTH.

0 commit comments

Comments
 (0)