Metadata-Version: 2.1
Name: conflateddict
Version: 0.1.1
Summary: Classes to help conflate streaming data.
Home-page: https://github.com/christianreimer/conflateddict
Author: Christian Reimer
Author-email: christian.reimer@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: License :: OSI Approved :: MIT License

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
    >>>


