Skip to main content

English description follows Japanese.


obj-hash Documentation (English)

Overview

obj-hash is a Python library that generates fast, deterministic hash values from JSON-serializable objects.

Unlike Python’s built-in hash() function, which produces different values on each interpreter run, obj-hash always returns the same hash for the same logical object structure.

Key Features

  • Deterministic hashing for JSON-serializable objects
  • Order-independent hashing for dictionaries and similar structures
  • Uses BLAKE3, which is faster than SHA-256
  • Default output length is 16 bytes (same number of combinations as UUID)

How It Works (Conceptually)

The input object is interpreted by its logical structure and values, not by incidental factors such as:

  • Dictionary key insertion order
  • Runtime-specific hash seeds

Objects that are logically equivalent (for example, dictionaries with the same keys and values but different orderings) produce the same hash value.

Usage Example

import obj_hash

h = obj_hash("hogehoge")
print(h)
# -> 66787eb34e4b87df2788806ba4750390

print(obj_hash({"23": "hoge", "list": []}))
# -> 1e3145f8a5679e6a00a802f88b7b5ba8

print(obj_hash({"23": "hoge", "list": []}, length=100))
# -> 1e3145f... (100 characters)

print(
  obj_hash({"23": "hoge", "list": []})
  == obj_hash({"list": [], "23": "hoge"})
)
# -> True

Parameters

  • object

    • Any JSON-serializable Python object
  • length (optional)

    • Length of the hexadecimal hash string
    • Default: 16 bytes (32 hex characters)

obj-hash ドキュメント(日本語)

概要

obj-hash は、JSON化可能なオブジェクトを高速かつ決定的にハッシュ化する Python ライブラリです。

Python 標準の hash() は実行ごとに値が変わりますが、obj-hash は常に同じ論理構造に対して同じハッシュ値を返します。

特徴

  • JSON化可能なオブジェクトを決定的にハッシュ化
  • 辞書のキー順序に依存しない
  • SHA-256 より高速な BLAKE3 を内部で使用
  • デフォルトの出力長は 16バイト(UUIDと同等の組み合わせ数)

論理的な動作について

このライブラリは、オブジェクトを 見た目ではなく意味的な構造 として扱います。

そのため、以下のような要素はハッシュ値に影響しません。

  • 辞書のキー追加順序
  • 実行環境や起動回ごとの差異

同じ内容を表すオブジェクトであれば、構造が同一と判断され、必ず同じハッシュ値が生成されます。

使い方

import obj_hash

h = obj_hash("hogehoge")
print(h)
# -> 66787eb34e4b87df2788806ba4750390

print(obj_hash({"23": "hoge", "list": []}))
# -> 1e3145f8a5679e6a00a802f88b7b5ba8

print(obj_hash({"23": "hoge", "list": []}, length=100))
# -> 1e3145f...(100桁)

print(
  obj_hash({"23": "hoge", "list": []})
  == obj_hash({"list": [], "23": "hoge"})
)
# -> True

引数

  • object

    • JSON化可能な任意の Python オブジェクト
  • length(省略可)

    • 16進文字列としての出力長
    • デフォルトは 16バイト(32文字)

Metadata

Release files for obj-hash 0.0.0

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

Source distribution (sdist)

Source distribution for obj-hash 0.0.0
File Size Uploaded Provenance
obj_hash-0.0.0.tar.gz 3.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for obj-hash 0.0.0
File Interpreter ABI Platform
obj_hash-0.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.3 kB

Release files / obj_hash-0.0.0.tar.gz

Download URL obj_hash-0.0.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2ca5c7ee5fb912f3929b3c430492980836541c7fcade98a1d8acd6a19be78d37
BLAKE2b-256 checksum
How to use checksums
b046a2d7ffc62941363d504a291ea281268174b5e9cfc12b8b4dae110b432073
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.3

Release files / obj_hash-0.0.0-py3-none-any.whl

Download URL obj_hash-0.0.0-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
665ff4aeea3eeecf11056962f634415d4e4ff038b7a7e0d3e911cc7b4980a015
BLAKE2b-256 checksum
How to use checksums
613cd9f3e0a2c544449de8194a3dc8bd8a298bc079fd5d17e45494febb4e56fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.3

Security for obj-hash 0.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 release files No provenance

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