semvec/pypi-packages huggingface dataset:
dict-sourcer 0.3.0
A Python package for reducing mapping-like objects using reducer objects, implemented in Rust.
License: MIT
Requires Python: >=3.6

# dict-sourcer

## Build for PyPi

docker run --rm -v "$(pwd)":/ci quay.io/pypa/manylinux2014_x86_64 /ci/build.sh
pypi_publish.sh

or

```
python setup.py sdist bdist_wheel

export TWINE_USERNAME=__token__
export TWINE_PASSWORD=<password>

twine upload target/wheels/*
```

### Notice

When upgrading version should be changes
in:
 - setup.py
 - Cargo.toml
 - pyproject.toml

## Example use

```python
from event_sourcer import reduce_dict

class SumReducer:
    def init(self):
        return 0
    def update(self, acc, value):
        return acc + value
    def finalize(self, acc):
        return acc

class AvgReducer:
    def init(self):
        return (0, 0)  # (total, count)
    def update(self, acc, value):
        total, count = acc
        return (total + value, count + 1)
    def finalize(self, acc):
        total, count = acc
        return total / count if count else None

# Any object supporting __getitem__ will work; here we use dicts.
def generate_objects():
    yield {"a": 1, "b": 4}
    yield {"a": 1, "c": 4}

reducers = {
    "a": SumReducer(),
    "b": AvgReducer(),
    "c": AvgReducer(),
    "d": SumReducer(),
}

result = reduce_dict(generate_objects(), reducers)
print(result)
```