Deep compare python structures like dictionaries, lists and iterables.
Project description
Deepcomparer
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
Release history Release notifications | RSS feed
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.0.9.tar.gz
(3.2 kB
view hashes)
Built Distribution
Close
Hashes for deepcomparer-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c214e72db3f19c8667295a519a712c096d142bccd65d9505411d0cfb88f3450 |
|
MD5 | 2969d61405ed31136fb89cc7a170e9eb |
|
BLAKE2b-256 | d42937a986a8bf7e432a753a818c548bd2bb95246ea9fd104a7919c7450e3ee9 |