Classes to help conflate streaming data.
Project description
This module contains classes to assist with conflating streaming data. This can be used to manage the load on consuming tasks, and is especially useful if the consumers only need the current value and can thus safely discard intermediate updates.
- Example:
>>> from conflateddict import ConflatedDict >>> import random >>> >>> keys = ['red', 'green', 'blue', 'orange'] >>> con = ConflatedDict() >>> for _ in range(100): ... con[random.choice(keys)] = random.randint(0, 100) ... >>> print(list(con.items()) [('orange', 32), ('green', 71), ('red', 71), ('blue', 80)] >>> print(len(con)) 4 >>> # After a reset, there will be no dirty values >>> con.reset() >>> print(list(con.items()) [] >>> print(len(con)) 0 >>> # After another update, any new dirty values will be returned >>> con[random.choice(keys)] = random.randint(0, 100) >>> print(list(con.items()) [('orange', 58)] >>> >>> # We still have access to all the values through data() >>> print(list(con.data().items())) [('blue', 80), ('red', 71), ('green', 71), ('orange', 58)] >>> print(len(con.data())) 4 >>>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
conflateddict-0.1.2.tar.gz
(4.8 kB
view hashes)
Built Distribution
Close
Hashes for conflateddict-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b24b8f4627e760f2f38e72df007fead29a13ae601c6bd9a72208a14eb12c41c |
|
MD5 | 9b3e3265940b8b82703b4472eb01e2c9 |
|
BLAKE2b-256 | 2ff4cac8ccbc21492480192a27948cb40038a60f3cf209f669f43149fbdd6055 |