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.3-cp314-cp314-win_amd64.whl (41.1 kB view details)

Uploaded CPython 3.14Windows x86-64

frozen_cub-0.2.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (196.5 kB view details)

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

frozen_cub-0.2.3-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (190.7 kB view details)

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

frozen_cub-0.2.3-cp314-cp314-macosx_11_0_arm64.whl (74.1 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

frozen_cub-0.2.3-cp313-cp313-win_amd64.whl (41.0 kB view details)

Uploaded CPython 3.13Windows x86-64

frozen_cub-0.2.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (196.4 kB view details)

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

frozen_cub-0.2.3-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (191.1 kB view details)

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

frozen_cub-0.2.3-cp313-cp313-macosx_11_0_arm64.whl (74.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

frozen_cub-0.2.3-cp312-cp312-win_amd64.whl (41.0 kB view details)

Uploaded CPython 3.12Windows x86-64

frozen_cub-0.2.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (196.0 kB view details)

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

frozen_cub-0.2.3-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (190.9 kB view details)

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

frozen_cub-0.2.3-cp312-cp312-macosx_11_0_arm64.whl (74.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: frozen_cub-0.2.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 41.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.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 bb69bd91e9e52e703b0db5ce306fb2692674deb17ebbae4c4cf6c498f80565b5
MD5 d2294978951d0a80477ce37e45e2ccbf
BLAKE2b-256 28e20dffebc79885b805a6ea61dd4ccf08a61646f36f50df0940a8cc75c61e55

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 248bf0da6a8681d68d96698cedeaff0b01860d4d73446a54824d01f7b06eb692
MD5 2bb4d3493e6967c90fe6607db97d2968
BLAKE2b-256 a2e7f2b25ec7e3adddd520425e7ce31cf1e593a4553f6e1cde3dd67ea2ec6b6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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.3-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.3-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 24c88f06d751123de3de790b4d8160acf409e3ddebe739033354ef926084b55c
MD5 07fc406d7174cd8875619e3779e99823
BLAKE2b-256 409e53d9b21e657ce1420293694044d121b8904b640cf9c04f11b9a7d4d73ebc

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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.3-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 124d7b42a4f59242af79718fb70d4755fb18bd0114302da5d4584dca262c9172
MD5 ffceccbb2634cb37db494bb3242eadf4
BLAKE2b-256 811a6c7e6a4c585b96e83f7204a2c9e387bfad25ebdfc6e9a45baef9e6868965

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: frozen_cub-0.2.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 41.0 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 275f753f0b738fa8417cd2de9183f31a9524f54bbca170c206ab8cf144d34fc2
MD5 b9082e8876226c44c53976f969922711
BLAKE2b-256 0ae6deca793add31dc6a7f6367365b094ef40efe2f5ae43748662eda62c04ff4

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 33f782ad50a3f59181401a5c63cb171c64e5dbee48be033d5c0e13aff8a7143a
MD5 1e9a3143df5d2356f0acc958794a1615
BLAKE2b-256 1160d8013b1a54cf170ca7e1b5374159a9bef5a675614a4d6052dec8d018b818

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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.3-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.3-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 2c70ab78f71d2d51b8e5a23a36c94e0343b207b7376ed1ca35f745871d143d43
MD5 c42204781bad4fdf4892c8d299a25998
BLAKE2b-256 8f1674fa9c59feeb5e5819845daabb3e5bbebf192b2cf30e3990aca915f33f64

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2677ab0412ac22f2d2d1591e61c272e7cd2176fe1a553db91795bafbef3b2fce
MD5 1f8f4a8f05b4fa5002036bd92f8809b3
BLAKE2b-256 d269074e2979c71c872dc1688b0fc3410bdb0a46a69725032bdb8de0fc9be3f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: frozen_cub-0.2.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 41.0 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b1098ae6a550e7900dd78fdc7059129aa62fcaa82bea898d2cdbc446579c78b1
MD5 4f4151b85927b176a90a0a2d0d567897
BLAKE2b-256 bd4325a51cbef467e31d74a249c10371b6e0234b2ecdf0bb748bec56087c6298

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e0c8a010ec9bd588b7b5d0cd71ead73020af63c1b6a63ae44b0ddae1ad5304f0
MD5 9fc47a74bac88e3e6e4cfd493ddeddab
BLAKE2b-256 ac597ec38d9296ffa7b831e090fc42441cc06c60966e4d261ef18fd519f66238

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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.3-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.3-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 92469b49531d31ca00c24258713f11e23671cb686a60e52654a3d2ef04b64fd3
MD5 c7857f42ff57bcfc4ae5ebced5b1eda1
BLAKE2b-256 06459de5c5d47251335a14a213577b38106bb851f36ee72078494f6024b664f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for frozen_cub-0.2.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 572f0d052bd42b70b63ee5d171f3b207c80954caa2a2e7796690cb0d386f9476
MD5 a2a344ae94ad506128a28bf8b5e8acba
BLAKE2b-256 61926881121a9dc647ea345266cc1509222c966963ec0c185c3ae332c9787aeb

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.3-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