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.3.0.tar.gz
(3.2 kB
view hashes)
Built Distribution
Close
Hashes for deepcomparer-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 755c1e4a829431a50df05a72c9cea1baae0187d2688f51003c69153318b6283e |
|
MD5 | 9f0642a83680afab6c1812585f3438be |
|
BLAKE2b-256 | e18296ad034b97fd4ef6ce86cbc8758427dd2da73f8514f3031efaddc8bf9c4c |