Skip to main content

Deep compare python structures like dictionaries, lists and iterables.

Project description

Deepcomparer

GitHub Pypi Downloads GA

Deep compare python objects and structures like dictionaries, lists and iterables.

Getting Started

Installation

  pip install deepcomparer

Usage

from deepcomparer import deep_compare

class Pokemon:
    def __init__(self, name):
        self.name = name

user: dict = {
    'name': 'ash',
    'links': {
        'pokehub': '@ash'
    },
    'pokemons': [Pokemon('pikachu')]
}

user2: dict = {
    'name': 'ash',
    'links': {
        'pokehub': '@ash'
    },
    'pokemons': [Pokemon('geodude')]
}
print(deep_compare(user, user2))
# output: False

user2['pokemons'] = [Pokemon('pikachu')]
print(deep_compare(user, user2))
# output: True
from deepcomparer import deep_compare

ash_data: dict = {
    'name': 'ash',
    'links': {
        'pokehub': '@ash'
    }
}

brock_data: dict = {
    'name': 'brock',
    'links': {
        'pokehub': '@brock'
    }
}

# Over iterable structures
print(deep_compare([ash_data, brock_data], [ash_data, brock_data]))
# output: True

# Over iterable structures
print(deep_compare([ash_data, brock_data], [brock_data, ash_data]))
# output: False

# Over unsorted iterable structures
print(deep_compare([ash_data, brock_data], [brock_data, ash_data], ignore_order=True))
# output: True

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

deepcomparer-0.4.0.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

deepcomparer-0.4.0-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

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