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

Uploaded CPython 3.14Windows x86-64

frozen_cub-0.2.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (170.8 kB view details)

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

frozen_cub-0.2.4-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (165.0 kB view details)

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

frozen_cub-0.2.4-cp314-cp314-macosx_11_0_arm64.whl (48.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

frozen_cub-0.2.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (170.7 kB view details)

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

frozen_cub-0.2.4-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (165.4 kB view details)

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

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

frozen_cub-0.2.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (170.3 kB view details)

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

frozen_cub-0.2.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (165.2 kB view details)

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

frozen_cub-0.2.4-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.4-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: frozen_cub-0.2.4-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.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 2080e1252e9d9c0179020ada0555710cdc10f5f9e9083c1b7d3c63e26118b2da
MD5 c1372137b77374160c575cc927ad51da
BLAKE2b-256 eae2daf48a0b7284493186b50d74a13d6d39a31607d2d9885e3744b64f533019

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for frozen_cub-0.2.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 eba24150dcc2d784c6703293523b8c08e8fa7a914f033deb952e836c22604e4a
MD5 3f7777274bf90e259939858aba93317c
BLAKE2b-256 b7a1af07dd46c41a1bcdbccd61afa8e72cf5f7026f4fe114b75f57e70fd2f754

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.4-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.4-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.4-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 8b7811f7bc8b11bc0c814dc4078146883282881e455193f74708091441ace5ae
MD5 d4b7e73441f472eb4e9e052c52c7e7ac
BLAKE2b-256 d0a83dcd7208613c68a5de8120cbb8572e62d4dff1e7b046198767916fc19267

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for frozen_cub-0.2.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b833bd44a659ee07e7d3f1e5ef8ac84498c558eec756e1f1aaffd818439fc88
MD5 cfd63406214e4e31599627fc54d23de4
BLAKE2b-256 8f7ab767ec0739b0b0a3f45946c875d4d3069e0e881b96a97d0dc05249ba42ac

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: frozen_cub-0.2.4-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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 608b70914ca3b2f4dd588bc1ab07595a0bc9fb5b8266312efc62e91426eb4744
MD5 7d391b425efd98976c111d8e0d04fc7d
BLAKE2b-256 57c301ee1aee5ed6a59621a6563da6037d29b8bad6f4c07500db4f6e378d2809

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for frozen_cub-0.2.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ea40b88b6dc0a38ebd64715b0f2e2996be76623d6e368b67a10cb0563b8bafc4
MD5 7d74ded8c7e9c33320d26a73e5f47bdd
BLAKE2b-256 64736883a66e71ae7014d34e0545784fe68e54e4caee12874849eac9a29f88f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.4-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.4-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.4-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 af8f58ab28685fdf7344b9081094e7e119ce9450685f25fd58184c00c47f6da2
MD5 8091d019366adfbab72f01b8aa1204af
BLAKE2b-256 530470cc28e4110aacfced39c92e3397d0f57daeaa51c9e667c55fee1591b08c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for frozen_cub-0.2.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b5b592c2cc967d7fd5ee3d80bd3a6e8b7847e7d813c07c7c79505f4d3f1cd4ea
MD5 29ff377271edf1b712eba1880a34057e
BLAKE2b-256 ee141fd52c9d0aa953a32302771a3a2e7acea75fd086eecfec54ffaa76a634f2

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: frozen_cub-0.2.4-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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7e0ffb22cbc37908be1bf0cc36b2fa7eeb8323cce8757dbe74fe7b1c6bc90fd8
MD5 a360757bea88f84a98aa5c8c039e1afa
BLAKE2b-256 6bdf38ed8dac3ac5a004b7bd9dd6d12293ff100d2ca6f47eeeb1b7bf0f38fd8a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for frozen_cub-0.2.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 76a1e3dbe74dec6f7b3eacc98d6b30eac82246dc26d10159bbac60b554fb1cf5
MD5 8c600167823c3f06ad5ce9af41f65f2d
BLAKE2b-256 c5e565804d5c67658d39d2b448ac5eeb203411701fd9362b0ead574cc99f06a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for frozen_cub-0.2.4-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.4-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.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 53bbebd9b1151ce0e001d1faa38baa06daa42d9b978f3a62b3ba546869391093
MD5 3e3f4e8ae6c029fc8fd232e0ee3f7d70
BLAKE2b-256 ae8b3f7e5db82b1b13aa1f501ab3c9d381f737ada05de15bff8e188fc93fa2db

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for frozen_cub-0.2.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 422551d21aa18cbe7926941805f10b86d8f0f3973572e9e696c49c32d06ef37d
MD5 ca490fa6f9339e6adce37c9406b61b0b
BLAKE2b-256 de7defa46d5d2e01bccd2754b1d486734ded602e9861c26ecb74e3447972b575

See more details on using hashes here.

Provenance

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