Skip to main content

deepmerge

https://img.shields.io/pypi/v/deepmerge.svg https://img.shields.io/pypi/status/deepmerge.svg https://img.shields.io/pypi/pyversions/pillar.svg https://img.shields.io/github/license/toumorokoshi/deepmerge.svg https://github.com/toumorokoshi/deepmerge/actions/workflows/python-package.yaml/badge.svg

A tool to handle merging of nested data structures in Python.

Installation

deepmerge is available on pypi:

pip install deepmerge

Example

Generic Strategy

from deepmerge import always_merger

base = {"foo": ["bar"]}
next = {"foo": ["baz"]}

expected_result = {'foo': ['bar', 'baz']}
result = always_merger.merge(base, next)

assert expected_result == result

Custom Strategy

from deepmerge import Merger

my_merger = Merger(
    # pass in a list of tuple, with the
    # strategies you are looking to apply
    # to each type.
    [
        (list, ["append"]),
        (dict, ["merge"]),
        (set, ["union"])
    ],
    # next, choose the fallback strategies,
    # applied to all other types:
    ["override"],
    # finally, choose the strategies in
    # the case where the types conflict:
    ["override"]
)
base = {"foo": ["bar"]}
next = {"bar": "baz"}
my_merger.merge(base, next)
assert base == {"foo": ["bar"], "bar": "baz"}

You can also pass in your own merge functions, instead of a string.

For more information, see the docs

Supported Versions

deepmerge is supported on Python 3.8+.

For older Python versions the last supported version of deepmerge is listed below:

  • 3.7 : 1.1.1

Metadata

Release files for deepmerge 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deepmerge 4.0.0
File Size Uploaded Provenance Actions
deepmerge-4.0.0.tar.gz 22.8 kB Without provenance Details for deepmerge-4.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for deepmerge 4.0.0
File Interpreter ABI Platform Actions
deepmerge-4.0.0-py3-none-any.whl Python 3 none any Details for deepmerge-4.0.0-py3-none-any.whl

Total release size: 38.2 kB

Release files / deepmerge-4.0.0.tar.gz

Download URL deepmerge-4.0.0.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
948565f2bc9cdb41259a4a23d26638e5840c9e084a343ab279ffd3edcfdf74d3
BLAKE2b-256 checksum
How to use checksums
cae95e99e56e03f9461858e686fdaf82e2516671bc1bd46f8b7ad7b9a8375f6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / deepmerge-4.0.0-py3-none-any.whl

Download URL deepmerge-4.0.0-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a36dd5810fc3b90bd3e0b681158221361d6a31a6109411b27b211b371fed6d5b
BLAKE2b-256 checksum
How to use checksums
c289362146b2ec7d0d503f824ac8496c88f0408ee0d39203b02cc10feac08146
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for deepmerge 4.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page