Install & Compatibility
Where this runs
tested against v0.0.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
merge
✓ from deep_merge import merge
✗ import deep_merge; deep_merge.merge(...)
The primary merge function is exposed directly.
This example demonstrates how to import and use the `merge` function. It highlights the in-place modification of the first dictionary and the list appending behavior.
from deep_merge import merge
d1 = {'a': 1, 'b': {'c': 2}, 'list_key': [1, 2]}
d2 = {'b': {'d': 3}, 'e': 4, 'list_key': [3, 4]}
# NOTE: d1 will be modified in-place by the merge function.
# If you need to preserve d1, pass a copy: merge(d1.copy(), d2)
merged_dict = merge(d1, d2)
print(merged_dict)
# Expected output: {'a': 1, 'b': {'c': 2, 'd': 3}, 'list_key': [1, 2, 3, 4], 'e': 4}
# Note how 'list_key' lists are appended.
Debug
Known issues
gotchaThe `merge` function modifies the first dictionary (the 'target') in-place. It does not return a new dictionary unless the 'target' dictionary is a copy itself.fixIf you need to preserve the original target dictionary, pass a copy to `merge`: `merged_dict = merge(original_dict.copy(), source_dict)`.
affects: All versions (0.0.1+)
gotchaWhen merging lists, `deep-merge` simply appends the source list to the target list. It does not perform any deep merging or unique item handling for list elements.fixBe aware of this behavior. If you need custom list merging logic (e.g., merging unique items, or overwriting), you will need to implement it separately or use a different library.
affects: All versions (0.0.1+)
gotchaOnly dictionaries and lists have special merging logic. For other data types (e.g., integers, strings, tuples, sets), the value from the source dictionary will simply overwrite the value in the target dictionary.fixUnderstand that non-dict/non-list values are overwritten. Plan accordingly if your nested structures contain types that require custom merging behavior.
affects: All versions (0.0.1+)
Errors
Common errors & fixes
AttributeError: module 'deep_merge' has no attribute 'merge'
Attempting to call `deep_merge.merge()` after `import deep_merge`.
fixThe `merge` function is directly exposed. Use `from deep_merge import merge` and then call `merge()`.
My original dictionary was modified unexpectedly after calling merge!
The `merge` function performs an in-place modification of the first argument (the 'target' dictionary).
fixPass a copy of your dictionary if you wish to preserve the original: `merged_dict = merge(my_original_dict.copy(), other_dict)`.
Lists are being appended, not truly merged (e.g., unique items not preserved).
The library's design for lists is to concatenate them (`target_list + source_list`), not to perform deep or intelligent merging of list elements.
fixThis is expected behavior for `deep-merge`. If you require more sophisticated list merging, consider pre-processing your lists or using a library with configurable list merge strategies.
Upgrade
Version history
0.0.4latest on PyPI · released Mar 27, 2018
Audit
Dependencies
No dependency data recorded yet.