Skip to main content

A set of C and Python implementations of immutable, hashable, and performant frozen objects.

Project description

Frozen Cub

pypi version

A high-performance library for immutable, hashable data structures in Python. Built with Cython for speed.

Supports Python 3.12, 3.13, and 3.14

Features

  • FrozenDict: An immutable dictionary that can be used as a dict key or in sets
  • freeze(): Recursively freeze nested data structures (dicts, lists, tuples, sets)
  • LRUCache: A fast LRU cache with O(1) operations
  • CacheKey: A lightweight hashable key for caching based on two values

Installation

pip install frozen-cub

With uv:

uv add frozen-cub

Quick Start

Freezing Data Structures

from frozen_cub.frozen import freeze, FrozenDict

# Freeze a nested dictionary
data = {
    "user": "bear",
    "settings": {"theme": "dark", "notifications": True},
    "tags": ["python", "cython"],
}
frozen = freeze(data)

# Now it's hashable - use as dict key or in sets
cache = {frozen: "some_result"}
unique_configs = {frozen}

FrozenDict

from frozen_cub.frozen import FrozenDict

# Create directly from items
fd = FrozenDict([("a", 1), ("b", 2)])

# Or from a dict
fd = FrozenDict({"a": 1, "b": 2})

# Access like a regular dict
print(fd["a"])  # 1
print(fd.get("c", "default"))  # "default"
print(list(fd.keys()))  # ["a", "b"]

# Use as a dict key (it's hashable!)
lookup = {fd: "found it"}

LRU Cache

from frozen_cub.lru_cache import LRUCache

# Create a cache with max 100 items
cache: LRUCache[str, dict] = LRUCache(capacity=100)

# Basic operations
cache["key"] = {"data": "value"}
result = cache.get("key")  # Returns {"data": "value"}
result = cache.get("missing", "default")  # Returns "default"

# Dict-like interface
"key" in cache  # True
del cache["key"]
len(cache)  # 0

CacheKey

from frozen_cub.utils import CacheKey

# Create a hashable key from two values
key = CacheKey(int, 42)

# Use as dict key or in sets
cache = {key: "cached_value"}

# For more than two values, use tuples
key = CacheKey("my_cache", (arg1, arg2, arg3))

Cython API

For maximum performance in other Cython code, you can use the inlined C functions directly:

from frozen_cub.frozen cimport inline_freeze, FrozenDict

# inline_freeze is inlined at compile time - zero function call overhead
cdef object frozen = inline_freeze(my_dict)

API Reference

freeze(obj)

Recursively converts mutable objects to immutable equivalents:

Input Type Output Type
dict FrozenDict
list tuple
set frozenset

FrozenDict

An immutable, hashable dictionary.

Methods:

  • get(key, default=None) - Get value with optional default
  • keys() - Return list of keys
  • values() - Return list of values
  • items() - Return list of (key, value) tuples
  • __getitem__(key) - Get value, raises KeyError if missing
  • __contains__(key) - Check if key exists
  • __hash__() - Returns cached hash value
  • __len__() - Return number of items

LRUCache[K, V]

A generic LRU cache with configurable capacity.

Constructor:

  • LRUCache(capacity=512) - Create cache with max capacity

Methods:

  • get(key, default=None) - Get value with optional default
  • set(key, value) - Set value (alias for __setitem__)
  • pop(key, default=None) - Remove and return value
  • clear() - Remove all items
  • __getitem__(key) - Get value, raises KeyError if missing
  • __setitem__(key, value) - Set value
  • __delitem__(key) - Delete key, raises KeyError if missing
  • __contains__(key) - Check if key exists
  • __len__() - Return number of items

CacheKey

A lightweight, hashable key for caching based on two values.

Constructor:

  • CacheKey(value1, value2) - Create a cache key from two hashable values

Methods:

  • __hash__() - Returns cached hash value
  • __eq__(other) - Compare equality with another CacheKey

Project details


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 Distributions

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

frozen_cub-0.2.5-cp314-cp314-win_amd64.whl (15.1 kB view details)

Uploaded CPython 3.14Windows x86-64

frozen_cub-0.2.5-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (170.7 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

frozen_cub-0.2.5-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (164.9 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

frozen_cub-0.2.5-cp314-cp314-macosx_11_0_arm64.whl (48.5 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

frozen_cub-0.2.5-cp313-cp313-win_amd64.whl (15.1 kB view details)

Uploaded CPython 3.13Windows x86-64

frozen_cub-0.2.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (170.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

frozen_cub-0.2.5-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (165.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

frozen_cub-0.2.5-cp313-cp313-macosx_11_0_arm64.whl (48.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

frozen_cub-0.2.5-cp312-cp312-win_amd64.whl (15.1 kB view details)

Uploaded CPython 3.12Windows x86-64

frozen_cub-0.2.5-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (170.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

frozen_cub-0.2.5-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (165.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

frozen_cub-0.2.5-cp312-cp312-macosx_11_0_arm64.whl (48.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file frozen_cub-0.2.5-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: frozen_cub-0.2.5-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for frozen_cub-0.2.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 704490cc4302053b76347b3aefe967a9ea995804c0feb36b99b534c3a8d8697f
MD5 ea83cedfe9b2bd62bb3fd5916d8a32ee
BLAKE2b-256 1227bf83fbacfd32ea59af79a8f652b563e51854aca85185eb741713890bc86e

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp314-cp314-win_amd64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frozen_cub-0.2.5-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.5-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 43f5e688136e80aa18bdb7cea341292757dd2b9842672e6cdaf5d783a1550236
MD5 4651542c2e9584f42fe38798dee2265a
BLAKE2b-256 0ea9fb0a273b92956a08ccbed3ca57d8a103d3f17a3936c81e1a9727d495abc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frozen_cub-0.2.5-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.5-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 97e59fb9e3a5ceae426d4089bac374badbc27a0e1359378d21c8133cfaab91db
MD5 886575253a140c00761d610d71ccb15f
BLAKE2b-256 c86ff5b3a5ae6805556ec0aa9894b1197e10370185ee7a847dcd6e4b9a07f94e

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frozen_cub-0.2.5-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.5-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28a277bfcc868264a10ac775672672c7469992dd5e0e0a0daccbb8bf3bfe2c01
MD5 8acb8c4c514b38689d5cd668981c980e
BLAKE2b-256 e5b1b60ab83a5be14ba95bee4e14d0c92390eb2a3538e7b005096575ab777966

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frozen_cub-0.2.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: frozen_cub-0.2.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for frozen_cub-0.2.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7b724bfa1a1b6d2c4138521affdb11a037fdf35e05b1e8d618a4c87273bb6eef
MD5 f4361f1e0a5bd3927e2630789d41e3a8
BLAKE2b-256 115b7e23a978972318c4598aaaed29b0174823f7d1bc4ce60499d3755d0a095c

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp313-cp313-win_amd64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frozen_cub-0.2.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 95758effd5da593862b6d4201b437a209733ace7514b972b5bc5b76fdd1e033e
MD5 feec25ff9905355535608a39e17bfe01
BLAKE2b-256 09635b8ba0508d322e25e72b99d2768cf2b53d8ba4b8f1a0e55e537d925bc0c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frozen_cub-0.2.5-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.5-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 80345dea22ff74f596236d089ace1289022393da8f3d35ea00e9097851ace437
MD5 2678e6c3b676134c46783f67714b1470
BLAKE2b-256 7d010efc5a6b8699d0268aa3cde4b7c115231bdb68dd957f11e5d2d5f6fa3cad

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frozen_cub-0.2.5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 195582aeff38d136daeafcdbeb739f26c7ed2a7d9b3861932d79360d5dec03d4
MD5 eae554d121b50ed3dde62b19f1403918
BLAKE2b-256 ce433eff66b75289472f5cd8a4ed036773bfe2292ba82a6348802cb5d23cd36b

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frozen_cub-0.2.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: frozen_cub-0.2.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for frozen_cub-0.2.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c6df91d1585dfe2c6adf1ef264405e9da0a52b55cab6c2bca6e18b11c2ac3227
MD5 47b12317d076b3a8c5ee11e9da0a102d
BLAKE2b-256 12b2f6f28352d8e6aea918b07de0592d49defb9364d0acde219d54c71eb36e2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp312-cp312-win_amd64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frozen_cub-0.2.5-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.5-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2a438becad3e80f7c529ff727a8bd91bd493e88658fb0e0fd44f6930aa47ef7f
MD5 66d9ad54ed63e64bc30cd96c3f505416
BLAKE2b-256 248b55a4746b6b8939cbc392cfc20b84881bf598b3c1ff04d34a63d46108f0a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frozen_cub-0.2.5-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.5-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 656e8225ecf1c872a43bae60b64c0b210a628bd9a94bb326f971433643e6ad72
MD5 ac0d13a69bf6d57c07c3279ecf88c7c2
BLAKE2b-256 dbda0beeee648c97748ce0f0c3c757f8b9273eba581029bc8810e091c058581d

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frozen_cub-0.2.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f6b7ea18ca9a59ebc3f07e293e8fcbb6f7b1b431fc07b497e40341098589bd8e
MD5 f8a1a81db836ea00c572693843fc072d
BLAKE2b-256 d5127eb31ab9aca7ce424fb02c68ac3a879a158eb7556ad58bbb94dd9890fea3

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.5-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on sicksubroutine/frozen-cub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page