Skip to content

Commit d96489d

Browse files
committed
1.2.0
1 parent 4a3a2da commit d96489d

File tree

9 files changed

+41
-5
lines changed

9 files changed

+41
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ filter.contains("अ") # returns true
2828
# next returns true
2929
filter[51] #You can use __getitem__ instead of contains
3030
filter[""] # returns false
31+
12.3 in filter # returns true
3132
```
3233

3334

pyfusefilter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from pyfusefilter.pyfusefilter import Xor8, Xor16, Fuse8, Fuse16
22

3-
VERSION = "1.1.5"
3+
VERSION = "1.2.0"
44
__all__ = ["Xor8", "Xor16", "Fuse8", "Fuse16"]

pyfusefilter/pyfusefilter.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ def __getitem__(self, item):
4444
"""
4545
return self.contains(item)
4646

47+
def __contains__(self, item):
48+
"""
49+
Check if the item is in the filter. With a small probability, the filter
50+
may return true for an item not in the set (false positive). There is
51+
no false negative: if the filter returns false, the item is definitely not in the set.
52+
"""
53+
return self.contains(item)
54+
4755
def __del__(self):
4856
lib.xor8_free(self.__filter)
4957

@@ -133,6 +141,14 @@ def __getitem__(self, item):
133141
"""
134142
return self.contains(item)
135143

144+
def __contains__(self, item):
145+
"""
146+
Check if the item is in the filter. With a small probability, the filter
147+
may return true for an item not in the set (false positive). There is
148+
no false negative: if the filter returns false, the item is definitely not in the set.
149+
"""
150+
return self.contains(item)
151+
136152
def __del__(self):
137153
"""
138154
Free the memory allocated for the Xor16 filter.
@@ -224,6 +240,14 @@ def __getitem__(self, item):
224240
"""
225241
return self.contains(item)
226242

243+
def __contains__(self, item):
244+
"""
245+
Check if the item is in the filter. With a small probability, the filter
246+
may return true for an item not in the set (false positive). There is
247+
no false negative: if the filter returns false, the item is definitely not in the set.
248+
"""
249+
return self.contains(item)
250+
227251
def __del__(self):
228252
"""
229253
Free the memory allocated for the Fuse8 filter.
@@ -315,6 +339,14 @@ def __getitem__(self, item):
315339
"""
316340
return self.contains(item)
317341

342+
def __contains__(self, item):
343+
"""
344+
Check if the item is in the filter. With a small probability, the filter
345+
may return true for an item not in the set (false positive). There is
346+
no false negative: if the filter returns false, the item is definitely not in the set.
347+
"""
348+
return self.contains(item)
349+
318350
def __del__(self):
319351
"""
320352
Free the memory allocated for the Fuse16 filter.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ py-modules = []
33
# cffi-modules handled in setup.py
44
[project]
55
name = "pyfusefilter"
6-
version = "1.1.5"
6+
version = "1.2.0"
77
description = "Python bindings for C implementation of xor and fuse filters"
88
authors = [
99
{name = "Amey Narkhede", email = "[email protected]"},
@@ -43,7 +43,7 @@ before-all = "apk add libffi-dev"
4343
# pdoc configuration
4444
name = "pyfusefilter"
4545
description = "Python bindings for C implementation of xor and fuse filters"
46-
version = "1.1.5"
46+
version = "1.2.0"
4747
author = "Amey Narkhede & Daniel Lemire"
4848
author_email = "[email protected]"
4949
url = "https://github.com/FastFilter/pyfusefilter"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name="pyfusefilter",
6-
version="1.1.5",
6+
version="1.2.0",
77
description="Python bindings for C implementation of xorfilter",
88
long_description=open("README.md", "r", encoding='utf-8').read(),
99
long_description_content_type="text/markdown",

tests/test_fuse16.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def test_readme():
99
assert filter.contains("अ") == True
1010
assert filter[51] #You can use __getitem__ instead of contains
1111
assert filter["か"] == False
12+
assert 12.3 in filter #You can use __contains__ instead of contains
1213

1314
def test_fuse16_int():
1415
xor_filter = Fuse16(50)

tests/test_fuse8.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def test_readme():
88
assert filter.contains("अ") == True
99
assert filter[51] #You can use __getitem__ instead of contains
1010
assert filter["か"] == False
11-
assert filter.contains(150) == False
11+
assert 12.3 in filter #You can use __contains__ instead of contains
1212

1313
def test_fuse8_int():
1414
xor_filter = Fuse8(50)

tests/test_xor16.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def test_readme():
88
assert filter.contains("अ") == True
99
assert filter[51] #You can use __getitem__ instead of contains
1010
assert filter["か"] == False
11+
assert 12.3 in filter #You can use __contains__ instead of contains
1112

1213
def test_xor16_int():
1314
xor_filter = Xor16(100)

tests/test_xor8.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def test_readme():
88
assert filter.contains("अ") == True
99
assert filter[51] #You can use __getitem__ instead of contains
1010
assert filter["か"] == False
11+
assert 12.3 in filter #You can use __contains__ instead of contains
1112

1213
def test_xor8_int():
1314
xor_filter = Xor8(50)

0 commit comments

Comments
 (0)