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.4.0.tar.gz
(3.2 kB
view details)
Built Distribution
File details
Details for the file deepcomparer-0.4.0.tar.gz
.
File metadata
- Download URL: deepcomparer-0.4.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c99a1fd328b350bbdfcf597f61e1cfb76d150c38dedf46ec709bf5eeeb7b88de |
|
MD5 | 44a7cd1da39b7158103a89adc0d774f9 |
|
BLAKE2b-256 | 4b3384a4de3c7081ea7132d6dcae54243ec56f1a77bb7f30f184f0fe7813ea73 |
File details
Details for the file deepcomparer-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: deepcomparer-0.4.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89d92f2c14e0d7afc9451739fc1228a46028054182b1387a5710a7ad2cf4d46b |
|
MD5 | 279df7a8c68a6a7aa5ddae4de8c2f05b |
|
BLAKE2b-256 | 0063815fc0dacdd898cfa9e9145982fbac94160581170e6a5dc51cc0abe8b43c |