Skip to main content

Canonical Hash

Deterministic hashing for arbitrary Python objects.

Provides utilities for creating stable, deterministic hashes of Python objects, essential for cache key computation, data versioning, and reproducibility.

Usage

from scicanonicalhash import canonical_hash, generate_record_id

# Hash any supported Python object
h = canonical_hash(42)
h = canonical_hash([1, 2, 3])
h = canonical_hash({"key": "value"})

# Generates a 16-character hex string (first 64 bits of SHA-256)
assert len(h) == 16
assert canonical_hash(42) == canonical_hash(42)  # Deterministic

Supported Types

  1. JSON-serializable primitives (None, bool, int, float, str)
  2. numpy ndarrays (via shape + dtype + raw bytes)
  3. pandas DataFrames (via columns + index + array serialization)
  4. pandas Series (via name + array serialization)
  5. Dicts (sorted keys, recursive serialization)
  6. Lists/tuples (order-preserving, recursive serialization)
  7. Datetimes: datetime.datetime, pd.Timestamp, np.datetime64 (any unit) and NaT. One spelling across the three types for the same value; an aware value hashes its UTC instant PLUS its zone label (zone_label: IANA name, "UTC", or a fixed offset like "+02:00"), which sciduckdb stores and restores. Owner: scicanonicalhash.datetimes. datetime64 ARRAYS keep their raw-bytes form.

generate_record_id

Generate a unique record ID from type, schema version, content hash, and metadata:

rid = generate_record_id("MyData", 1, "abc123", {"subject": 1})

Metadata

Release files for scicanonicalhash 0.2.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 scicanonicalhash 0.2.0
File Size Uploaded Provenance Actions
scicanonicalhash-0.2.0.tar.gz 12.8 kB With provenance Details for scicanonicalhash-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scicanonicalhash 0.2.0
File Interpreter ABI Platform Actions
scicanonicalhash-0.2.0-py3-none-any.whl Python 3 none any Details for scicanonicalhash-0.2.0-py3-none-any.whl

Total release size: 26.8 kB

Release files / scicanonicalhash-0.2.0.tar.gz

Download URL scicanonicalhash-0.2.0.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4d11a69e622d73aa996c811b9a1a5be6ffba0fe0fcad7ca8e61cfd5bc69869eb
BLAKE2b-256 checksum
How to use checksums
4c3b9f602f1ca00e4fc7f46a7c6b4b13007b95a2db6914d0d0fc6acf47afb3cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / scicanonicalhash-0.2.0-py3-none-any.whl

Download URL scicanonicalhash-0.2.0-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e25bd2ae1571aaac925e5e26be5ed8d11b25157389b60b6ba595347cbdb184bd
BLAKE2b-256 checksum
How to use checksums
99a01babe1c0b184b63677e38eab892314ebf26768f77f31ee08d565e5a94c00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for scicanonicalhash 0.2.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for scicanonicalhash-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

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.2.0 This release

2 release files Full 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