Hydrate Python dictionaries with Rust.
A general-purpose algorithm, used in pgstac to reduce the size of the items
table.
import hydraters
base = {"a": "first", "b": "second", "c": {"d": "third"}}
item = {"c": {"e": "fourth", "f": "fifth"}}
result = hyrdraters.hydrate(base, item)
assert result == {
"a": "first",
"b": "second",
"c": {"d": "third", "e": "fourth", "f": "fifth"},
}
python -m pip install hydraters
Or, if you're using uv:
uv add hydraters
git clone [email protected]:developmentseed/hydraters.git
cd hydraters
uv sync
uv run pre-commit install
To run tests:
uv run pytest
The code for this package was taken from pypgstac. It came from some benchmarking that determined it was much faster to do this operation in Rust than in pure Python.
MIT