Skip to main content

Fuso is a tool for merging data structures in Python. It provides a simple and intuitive API for merging dictionaries, lists, and other data structures.

Project description

Fuso

uv Ruff License: MIT Download/Month PyPI Version Read the Docs

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.
  • None in updates keeps the original value.
  • Merging non-None values of different types raises TypeError.
  • Duplicate lookup keys in to_list_of_dicts_by_key raise KeyError.

Ordering

  • merge_dict returns 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fuso-0.4.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fuso-0.4.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file fuso-0.4.0.tar.gz.

File metadata

  • Download URL: fuso-0.4.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for fuso-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ae16deca0c4386c0f25f575c38cc8195091ed5888549d6d0eb05ce521921ab48
MD5 0ce2ad7ca5bbd474826a02eb17cd9979
BLAKE2b-256 2d801e46066c90dfd858b7c4d14a1668ce25d01eb43e736e159a9610e9f7bb0e

See more details on using hashes here.

File details

Details for the file fuso-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: fuso-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for fuso-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0eb1496744f0c2af9ba575d1539d5723f2f2709273f4f455e506334bc8729ae
MD5 fd01a55dc0d9c5f8b871dcec8f657d79
BLAKE2b-256 c8b0a8e5e1a905f39498252d603b14571dc62d6cd6f68ef6506d9e7b7f329888

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page