Skip to main content

hashy

CI codecov PyPI version Python versions Downloads License: MIT Code style: black

Another hash library, but with a twist. It provides a simple interface to generate hashes for strings, files, dicts, lists and sets. It also provides a decorator to cache the results of a function to disk and (optionally) memory.

Installation

pip install hashy

Introduction

hashy provides an md5, sha256, sha512 or crc64nvme for string, file, dict, list and set.

String and file hashes are conventional and can be compared to other implementations. For example, you can go to an online hash calculator for "a" and get the same hash as hashy generates.

crc64nvme is the CRC-64/NVME checksum (as used by the NVMe specification and AWS S3 object integrity checking), returned as a 16-character hex string.

Hashes for complex data types like dict, list and set are specific to hashy.

Supports multithreading and multiprocessing, via the sqlitedict library. While the sqlite database itself is not thread-safe/process-safe, the sqlitedict library provides a thread-safe/process-safe interface.

cachy

hashy also provides cachy, a decorator that can be used to persistently cache the results of a function to disk and (optionally) memory. It is similar to @functools.cache, except:

  • Persistent (saved to local disk in a sqlite database)
    • Optionally can be saved to a user-specified directory, otherwise it's the usual cache directory for the OS
  • Optional user-specified cache life.
  • Doesn't require arguments be frozen and/or pickle-able. Uses hashy to create a hash of the arguments.

Example


from hashy import get_string_sha256, cachy

print(get_string_sha256("a"))  # prints ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb

@cachy()
def func(a):
    return a + a

print(func(2))  # prints 4

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hashy-0.14.1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file hashy-0.14.1-py3-none-any.whl.

File metadata

  • Download URL: hashy-0.14.1-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for hashy-0.14.1-py3-none-any.whl
Algorithm Hash digest
SHA256 314ed4444a1c7abaea547dd8af340747900d4848a4cdf84ca489a7b3900b3355
MD5 f5156cf3efe8d51cbf20930413f0a1de
BLAKE2b-256 48eec53730b0da10b86306a12663f1883b888c93ab46fae0a28eaa4c7fae534c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.14.1 This release

1 file

0.14.0

1 file

0.13.2

1 file

0.13.1

1 file

0.13.0

1 file

0.12.1

1 file

0.12.0

1 file

0.11.1

1 file

0.11.0

1 file

0.10.0

1 file

0.9.0

1 file

0.8.2

1 file

0.8.0

1 file

0.7.4

1 file

0.7.3

1 file

0.7.2

1 file

0.6.0

1 file

0.5.1

1 file

0.5.0

1 file

0.4.0

1 file

0.3.2

1 file

0.3.1

1 file

0.2.0

1 file

0.1.2

1 file

0.1.1

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 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