
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
A library for deep comparison of data structures consisting of `dict`, `list` and `tuple`.
deepcompare
is a library to deeply compare data structures with each other. It can check if two data
structures contain the same data, or if a data structure is a subset of another data structure. The library
supports Sequence
(e.g. list
or tuple
) and Mapping
(e.g. dict
) types for the deep comparison.
With a correctly configured pipenv
toolchain:
pipenv install python-deepcompare
You may also use classic pip
to install the package:
pip install python-deepcompare
Sequence
and all Mapping
types the same (e.g. (1, 2, 3)
is equal to
[1, 2, 3]
). To enable strict type checks, use the strict
keyword argument.partial_compare
method checks if the data structure given as the second parameter is a subset of the data
structure given as the first parameter.
Mapping
types this means, that all keys of the second data structure are also keys on the first data
structure, and the values of the keys are also equal (e.g. {'a': 1, 'b': 2}
is a subset
of {'a': 1, 'b': 2, 'c': 3}
, but {'a': 1, 'b': 2, 'd': 4}
is not).Sequence
types this means, that all values of the second data structure are also values of the first data
structure, and the values are in the same order (e.g. [1, 3, 5]
is a subset
of [1, 2, 3, 4, 5]
, but [1, 5, 3]
is not).import deepcompare
# test if two data structures are equal, but the types to not need to match exactly
deepcompare.compare(
{'key1': (1, 2, 3), 'key2': {'key3': [4, 5, 6]}},
{'key1': [1, 2, 3], 'key2': {'key3': (4, 5, 6)}},
) # returns: True
# test if two data structures are equal, and make sure the types match exactly
deepcompare.compare(
{'key1': (1, 2, 3), 'key2': {'key3': [4, 5, 6]}},
{'key1': [1, 2, 3], 'key2': {'key3': (4, 5, 6)}},
strict=True,
) # returns: False
# test if the second data structure is contained within the first, but
# the types to not need to match exactly
deepcompare.partial_compare(
{'key1': (1, 2, 3), 'key2': {'key3': [4, 5, 6]}, 'key4': True},
{'key1': [1, 2], 'key2': {'key3': (4, 6)}},
) # returns: True
# test if the second data structure is contained within the first, and
# make sure the types match exactly
deepcompare.partial_compare(
{'key1': (1, 2, 3), 'key2': {'key3': [4, 5, 6]}, 'key4': True},
{'key1': [1, 2], 'key2': {'key3': (4, 6)}},
strict=True,
) # returns: False
FAQs
A library for deep comparison of data structures consisting of `dict`, `list` and `tuple`.
We found that python-deepcompare demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.