hashy


Namehashy JSON
Version 0.11.0 PyPI version JSON
download
home_pagehttps://github.com/jamesabel/hashy
Summarysimple hash library for string, file, dict, set and list
upload_time2025-09-14 18:02:44
maintainerNone
docs_urlNone
authorabel
requires_pythonNone
licenseMIT License
keywords hash
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            
# hashy

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 or sha512 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.

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

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jamesabel/hashy",
    "name": "hashy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "hash",
    "author": "abel",
    "author_email": "j@abel.co",
    "download_url": "https://github.com/jamesabel/hashy",
    "platform": null,
    "description": "\r\n# hashy\r\n\r\nAnother hash library, but with a twist. It provides a simple interface to generate hashes for strings, files, dicts, \r\nlists and sets. It also provides a decorator to cache the results of a function to disk and (optionally) memory.\r\n\r\n## Installation\r\n\r\n```\r\npip install hashy\r\n```\r\n\r\n## Introduction\r\n\r\nhashy provides an md5, sha256 or sha512 for string, file, dict, list and set.\r\n\r\nString and file hashes are conventional and can be compared to other implementations. For example,\r\nyou can go to an online hash calculator for \"a\" and get the same hash as hashy generates.\r\n\r\nHashes for complex data types like dict, list and set are specific to hashy.\r\n\r\nSupports multithreading and multiprocessing, via the `sqlitedict` library. While the `sqlite` database itself is not \r\nthread-safe/process-safe, the `sqlitedict` library provides a thread-safe/process-safe interface.\r\n\r\n## cachy\r\n\r\n`hashy` also provides `cachy`, a decorator that can be used to persistently cache the results of a function to \r\ndisk and (optionally) memory. It is similar to `@functools.cache`, except:\r\n\r\n- Persistent (saved to local disk in a sqlite database)\r\n  - Optionally can be saved to a user-specified directory, otherwise it's the usual cache directory for the OS\r\n- Optional user-specified cache life.\r\n- Doesn't require arguments be frozen and/or pickle-able. Uses hashy to create a hash of the arguments.\r\n\r\n\r\n# Example\r\n\r\n```\r\n\r\nfrom hashy import get_string_sha256, cachy\r\n\r\nprint(get_string_sha256(\"a\"))  # prints ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb\r\n\r\n@cachy()\r\ndef func(a):\r\n    return a + a\r\n\r\nprint(func(2))  # prints 4\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "simple hash library for string, file, dict, set and list",
    "version": "0.11.0",
    "project_urls": {
        "Download": "https://github.com/jamesabel/hashy",
        "Homepage": "https://github.com/jamesabel/hashy"
    },
    "split_keywords": [
        "hash"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5768ddd43c0e0a0fdc267e0504cf85f5af097368e5c938aed94f5e23323922b6",
                "md5": "38382dddf4f097869e6567f05cac532b",
                "sha256": "cd4c4a57116e1a4340cf56ee06942919a89128f89b13573d18ba4e64d6a7b983"
            },
            "downloads": -1,
            "filename": "hashy-0.11.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "38382dddf4f097869e6567f05cac532b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10173,
            "upload_time": "2025-09-14T18:02:44",
            "upload_time_iso_8601": "2025-09-14T18:02:44.529553Z",
            "url": "https://files.pythonhosted.org/packages/57/68/ddd43c0e0a0fdc267e0504cf85f5af097368e5c938aed94f5e23323922b6/hashy-0.11.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-14 18:02:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jamesabel",
    "github_project": "hashy",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "hashy"
}
        
Elapsed time: 0.74037s