Fuso
fuso comes from the Italian word fusione, which translates to fusion. This is exactly what this library does; it creates a fusion between two dictionaries.
The goal of this library is to offer a customizable way of deeply merging dictionaries. In its simplest form, fuso offers an experience like other well-established dictionary merging libraries such as deepmerge, mergedeep.
However, where this library differs is that it allows the user to specify custom merge_functions for specific keys.
For example, you may want to concatenate lists for one key, but keep overwrite behavior for other keys. With fuso, this is possible.
Installation
You can install fuso via pip:
pip install fuso
Usage
Here's a basic example of how to use fuso to merge two dictionaries:
from fuso import merge_dict
dict1 = {"settings": {"theme": "dark", "plugins": ["plugin1", "plugin2"]}}
dict2 = {"settings": {"plugins": ["plugin3"], "language": "en"}}
merged_dict = merge_dict(dict1, dict2)
print(merged_dict)
# {
# "settings": {
# "theme": "dark",
# "plugins": ["plugin1", "plugin2", "plugin3"],
# "language": "en"
# }
# }
Merge semantics
- Dicts are merged recursively.
- Lists are concatenated.
- Scalars are overwritten by
updates. Noneinupdateskeeps the original value.- Merging non-
Nonevalues of different types raisesTypeError. - Duplicate lookup keys in
to_list_of_dicts_by_keyraiseKeyError.
Ordering
merge_dictreturns keys sorted alphabetically by default.- You can control key order with
key_order(partial orders are supported).
Documentation
For more detailed documentation, including advanced usage and customization options, please visit the official documentation.
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests on the GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Changes
To see changes by version check the changelog.
Metadata
Release files for fuso 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fuso-0.4.1.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fuso-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.3 kB
Release files / fuso-0.4.1.tar.gz
| Download URL | fuso-0.4.1.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e90ee52e0643a5d46394051b5f358184c1ae7775f852489e343361be5622b83
|
|
BLAKE2b-256 checksum How to use checksums |
98b3e000790cd990e29df34fbec95c91107481d0081beea4797436c2376da0c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fuso-0.4.1-py3-none-any.whl
| Download URL | fuso-0.4.1-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c62d94d39523adf63b1c1305a74662a61f2abbf0a6f6c536151ea7dc003cd05c
|
|
BLAKE2b-256 checksum How to use checksums |
843eb9de1b5a1a0c8e568baa19f40be81e4eaf00b7efc93de9b181ccccb2c692
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|