Skip to main content

Travis CI build SonarCloud Quality SonarCloud Maintainability Codacy Maintainability Maintainability Pypi project Pypi total project downloads

Simple python tool to hash dictionaries using both default hash and sha256. The library comes with full support for hashing Pandas DataFrame objects, Numba objects and Numpy arrays, but you will need to specify the requirements when installing the package to avoid bloating the installation process.

How do I install this package?

As usual, just download it using pip:

pip install dict_hash[all] # To install everything
pip install dict_hash[numba] # To install with numba support
pip install dict_hash[numpy] # To install with numpy support
pip install dict_hash[pandas] # To install with pandas support

Tests Coverage

Since some software handling coverages sometimes get slightly different results, here’s three of them:

Coveralls Coverage SonarCloud Coverage Code Climate Coverate

Usage examples

The package offers two functions: sha256 to generate constant sha256 hashes and dict_hash, to generate hashes using the native hash function.

Session hash with dict_hash

Obtain a session hash from the given dictionary.

from dict_hash import dict_hash
from random_dict import random_dict
from random import randint

d = random_dict(randint(1, 10), randint(1, 10))
my_hash = dict_hash(d)

Consistent hash with sha256

Obtain a consistent hash from the given dictionary.

from dict_hash import sha256
from random_dict import random_dict
from random import randint

d = random_dict(randint(1, 10), randint(1, 10))
my_hash = sha256(d)

Hashable

When handling complex objects within the dictionaries, you may need to implement the class Hashable in that object.

Here is an example:

from dict_hash import Hashable, sha256


class MyHashable(Hashable):

    def __init__(self, a: int):
        self._a = a
        self._time = time()

    def consistent_hash(self) -> str:
        return sha256({
            "a": self._a
        })

Release files for dict-hash 1.1.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dict-hash 1.1.14
File Size Uploaded
dict_hash-1.1.14.tar.gz 5.2 kB Details

Release files / dict_hash-1.1.14.tar.gz

Download URL dict_hash-1.1.14.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
830fb99db80b40568dd91bf094a63d2305a61f9901bae80a18f636f9d08c5b6f
BLAKE2b-256 checksum
How to use checksums
bb458dc033776b156537b51bfa6dcdb345a35d39a652d29070a01370ecdb14c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release history Release notifications | RSS feed

1.3.7

1 release file

1.3.6

1 release file

1.3.5

1 release file

1.3.4

1 release file

1.3.3

1 release file

1.3.2

1 release file

1.3.1

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.37

1 release file

1.1.36

1 release file

1.1.35

1 release file

1.1.33

1 release file

1.1.32

1 release file

1.1.31

1 release file

1.1.30

1 release file

1.1.29

1 release file

1.1.28

1 release file

1.1.27

1 release file

1.1.26

1 release file

1.1.25

1 release file

1.1.24

1 release file

1.1.23

1 release file

1.1.22

1 release file

1.1.21

1 release file

1.1.20

1 release file

1.1.19

1 release file

1.1.18

1 release file

1.1.17

1 release file

1.1.16

1 release file

1.1.15

1 release file

This release

1.1.14 This release

1 release file

1.1.13

1 release file

1.1.12

1 release file

1.1.11

1 release file

1.1.10

1 release file

1.1.9

1 release file

1.1.8

1 release file

1.1.7

1 release file

1.1.6

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page