Skip to content

Commit 22c3222

Browse files
author
Simon Prickett
committed
Updates for 2022 talk.
1 parent 7f95d9c commit 22c3222

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# No, Maybe and Close Enough!
22

3-
Exploring Probabilistic Data Structures in Python - my 2021 Pycon USA talk. If you'd like to see the slides for this talk, they're [here](https://simonprickett.dev/no_maybe_and_close_enough_slides.pdf) (PDF). Watch the video [here](https://www.youtube.com/watch?v=hM1JPkEUtks).
3+
Exploring Probabilistic Data Structures in Python - my 2021 Pycon USA and Australia talk. I've updated the code slightly for Pycon 2022 - it now uses the latest redis-py Redis client.
44

5-
This repository contains supporting code to run the examples from my talk. The example code uses in memory probabilistic data structures with the [hyperloglog](https://pypi.org/project/hyperloglog/) and [pyprobables](https://pypi.org/project/pyprobables/) libraries. It also uses [Redis](https://redis.io) with the [RedisBloom](https://redisbloom.io) module: this is provided for you as a Docker container.
5+
If you'd like to see the slides for the 2021 version of this talk, they're [here](https://simonprickett.dev/no_maybe_and_close_enough_slides.pdf) (PDF). Watch the 2021 video [here](https://www.youtube.com/watch?v=hM1JPkEUtks).
6+
7+
This repository contains supporting code to run the examples from my talk. The example code uses in memory probabilistic data structures with the [hyperloglog](https://pypi.org/project/hyperloglog/) and [pyprobables](https://pypi.org/project/pyprobables/) libraries. It also uses [Redis](https://redis.io) with the [RedisBloom](https://redisbloom.io) module: this is provided for you as part of [Redis Stack](https://redis.io/docs/stack/get-started/) in a Docker container.
68

79
The two probabilistic data structures examined in this code base are:
810

@@ -70,7 +72,7 @@ Approximate count with Python in memory HyperLogLog, compares count with an in m
7072

7173
```bash
7274
(venv) $ cd ../approximating_sheep_python
73-
(venv) $ python3 how_many.py
75+
(venv) $ python how_many.py
7476
There are 100000 sheep (set).
7577
There are 100075 sheep (hyperloglog).
7678
```

approximating_sheep_redis/have_i_seen_this_one.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
SHEEP_BLOOM_KEY = "sheep_seen_bloom"
66

77
redis_conn.delete(SHEEP_BLOOM_KEY)
8-
redis_conn.execute_command("BF.RESERVE", SHEEP_BLOOM_KEY, "0.001", 200000)
8+
redis_conn.bf().create(SHEEP_BLOOM_KEY, 0.001, 200000, noScale = True)
99

1010
for m in range(0, 100000):
1111
sheep_id = str(m)
12-
redis_conn.execute_command("BF.ADD", SHEEP_BLOOM_KEY, sheep_id)
12+
redis_conn.bf().add(SHEEP_BLOOM_KEY, sheep_id)
1313

1414
def have_i_seen(sheep_id):
15-
if redis_conn.execute_command("BF.EXISTS", SHEEP_BLOOM_KEY, sheep_id):
15+
if redis_conn.bf().exists(SHEEP_BLOOM_KEY, sheep_id):
1616
print(f"I might have seen sheep {sheep_id}.")
1717
else:
1818
print(f"I have not seen sheep {sheep_id}.")

requirements.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
hyperloglog==0.0.12
2-
pyprobables==0.4.0
3-
redis==3.5.3
1+
async-timeout==4.0.2
2+
Deprecated==1.2.13
3+
hyperloglog==0.0.13
4+
packaging==21.3
5+
pyparsing==3.0.9
6+
pyprobables==0.5.6
7+
redis==4.3.4
8+
wrapt==1.14.1

0 commit comments

Comments
 (0)