# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= python-mergedeep VERSION= 1.3.4 KEYWORDS= python VARIANTS= v11 v12 SDESC[v11]= Deep merge function for 🐍 (3.11) SDESC[v12]= Deep merge function for 🐍 (3.12) HOMEPAGE= https://github.com/clarketm/mergedeep CONTACT= Python_Automaton[python@ironwolf.systems] DOWNLOAD_GROUPS= main SITES[main]= PYPIWHL/2c/19/04f9b178c2d8a15b076c8b5140708fa6ffc5601fb6f1e975537072df5b2a DISTFILE[1]= mergedeep-1.3.4-py3-none-any.whl:main DF_INDEX= 1 SPKGS[v11]= single SPKGS[v12]= single OPTIONS_AVAILABLE= PY311 PY312 OPTIONS_STANDARD= none VOPTS[v11]= PY311=ON PY312=OFF VOPTS[v12]= PY311=OFF PY312=ON DISTNAME= mergedeep-1.3.4.dist-info GENERATED= yes [PY311].USES_ON= python:v11,wheel [PY312].USES_ON= python:v12,wheel [FILE:1935:descriptions/desc.single] # [mergedeep] [PyPi release] [PyPi versions] [Downloads] [Conda Version] [Conda Downloads] [Documentation Status] A deep merge function for 🐍. [Check out the mergedeep docs] ## Installation ```bash $ pip install mergedeep ``` ## Usage ```text merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy = Strategy.REPLACE) -> MutableMapping ``` Deep merge without mutating the source dicts. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merged = merge({}, a, b, c) print(merged) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` Deep merge into an existing dict. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merge(a, b, c) print(a) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` ### Merge strategies: 1. Replace (*default*) > `Strategy.REPLACE` ```python3 # When `destination` and `source` keys are the same, replace the `destination` value with one from `source` (default). # Note: with multiple sources, the `last` (i.e. rightmost) source value will be what appears in the merged result. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": [3, 4]} merge(dst, src, strategy=Strategy.REPLACE) # same as: merge(dst, src) print(dst) # {"key": [3, 4]} ``` 2. Additive > `Strategy.ADDITIVE` ```python3 # When `destination` and `source` values are both the same additive collection type, extend `destination` by adding values from `source`. # Additive collection types include: `list`, `tuple`, `set`, and `Counter` # Note: if the values are not additive collections of the same type, then fallback to a `REPLACE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2], "count": Counter({"a": 1, "b": 1})} src = {"key": [3, 4], "count": Counter({"a": 1, "c": 1})} merge(dst, src, strategy=Strategy.ADDITIVE) print(dst) [FILE:111:distinfo] 70775750742b25c0d8f36c55aed03d24c3384d17c951b3175d898bd778ef0307 6354 mergedeep-1.3.4-py3-none-any.whl