Skip to main content

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


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)

Uploaded Source

Built Distribution

conflateddict-0.1.2-py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page