Frozen Cub
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 defaultkeys()- Return list of keysvalues()- Return list of valuesitems()- Return list of (key, value) tuples__getitem__(key)- Get value, raisesKeyErrorif 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 defaultset(key, value)- Set value (alias for__setitem__)pop(key, default=None)- Remove and return valueclear()- Remove all items__getitem__(key)- Get value, raisesKeyErrorif missing__setitem__(key, value)- Set value__delitem__(key)- Delete key, raisesKeyErrorif 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
Metadata
Release files for frozen-cub 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 2.4 MB
Release files / frozen_cub-0.3.1-cp315-cp315-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | frozen_cub-0.3.1-cp315-cp315-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 262.3 kB |
| Tags | CPython 3.15 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
74e3feb4ae6068e3c20d9c6fc47d5b8b911c4bed1d19e7066a7114bdf0806ba3
|
|
BLAKE2b-256 checksum How to use checksums |
18d6118d97ed74501b43d1f49c2547f555cbbdc6432fab4ca52806c9de796386
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency logRelease files / frozen_cub-0.3.1-cp315-cp315-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
| Download URL | frozen_cub-0.3.1-cp315-cp315-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 271.9 kB |
| Tags | CPython 3.15 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
ba5e8a9a0459232a1dfca31ff6b805cf274f3d4a54601d3cc0028a4a1002e2b0
|
|
BLAKE2b-256 checksum How to use checksums |
362daf4f9ea11cc2ad7b2cfcf46a8859d4082c8fe708692419f6fff1ba49108c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency logRelease files / frozen_cub-0.3.1-cp315-cp315-macosx_15_0_arm64.whl
| Download URL | frozen_cub-0.3.1-cp315-cp315-macosx_15_0_arm64.whl |
|---|---|
| Size | 60.0 kB |
| Tags | CPython 3.15 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3ac188dc110cde0d552fdf3d292a4b86f57e2abc93174d5083512e76c35f55b8
|
|
BLAKE2b-256 checksum How to use checksums |
9c57afabe748743eca0ff09317d5debb91a5ba1389d0ff3cc22832d47a334fa4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency logRelease files / frozen_cub-0.3.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | frozen_cub-0.3.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 261.0 kB |
| Tags | CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
b762676f176b3d8989225d838acfaa6f95bcc517357e85e5c10b1bdacf48ad2d
|
|
BLAKE2b-256 checksum How to use checksums |
b5ea3b18e29bd477dcbf8f4a8d2cd76e0f17b477d7aeae1ee009179deec64471
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency logRelease files / frozen_cub-0.3.1-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
| Download URL | frozen_cub-0.3.1-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 269.6 kB |
| Tags | CPython 3.14 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
c0b3bbbfd5a0a5fa1bea531979cc3e9fc9f598181c91d28f6efed40aebe78644
|
|
BLAKE2b-256 checksum How to use checksums |
5a9b56494adfe381aed06ac6e7932beb0fb7d2629132eec3c22f15194bed15e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency logRelease files / frozen_cub-0.3.1-cp314-cp314-macosx_15_0_arm64.whl
| Download URL | frozen_cub-0.3.1-cp314-cp314-macosx_15_0_arm64.whl |
|---|---|
| Size | 59.9 kB |
| Tags | CPython 3.14 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6611c9c77d6b951057ff927ac408569427fac621cc3a388b4652d2bc40eea85f
|
|
BLAKE2b-256 checksum How to use checksums |
3ba77dd0d175a7c09b70c8a7c7e8ee92a442bef78e10962349165f6630f2f3b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency logRelease files / frozen_cub-0.3.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | frozen_cub-0.3.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 261.7 kB |
| Tags | CPython 3.13 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
798a4d34ed415ef9c70dce266e4b3ddc635413e8aaf01b17b77eb3dce32da1d6
|
|
BLAKE2b-256 checksum How to use checksums |
ad0c68091cb18a45ff605523e2e39c427f76cbe8997e02a7d43ed5f1120dee60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency logRelease files / frozen_cub-0.3.1-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
| Download URL | frozen_cub-0.3.1-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 269.4 kB |
| Tags | CPython 3.13 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
ba00c7f82c46ae0ab180a0af267dc9f13fb52353771ca159d51ea9b6538ff9ac
|
|
BLAKE2b-256 checksum How to use checksums |
ea6e5f7f1472178e9d32de14c94f2293eaf7c81d5331c7fb7573918d43017b08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency logRelease files / frozen_cub-0.3.1-cp313-cp313-macosx_15_0_arm64.whl
| Download URL | frozen_cub-0.3.1-cp313-cp313-macosx_15_0_arm64.whl |
|---|---|
| Size | 59.8 kB |
| Tags | CPython 3.13 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
053e72d732cc7fd8ccd0c1aab2b0911515bb6ca9b4f14cb9f299e7125ee331b7
|
|
BLAKE2b-256 checksum How to use checksums |
79013373bf468098ca7d0e80d402949a8306a19b455132050a5beebcde83895d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency logRelease files / frozen_cub-0.3.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | frozen_cub-0.3.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 261.4 kB |
| Tags | CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
02d102b90c86d72debdacfca39a16d45ac682f8427d4f856c91f61f9b53ec275
|
|
BLAKE2b-256 checksum How to use checksums |
59947ad7ee527c740c9ce69ac8bebc6d10529d4ee70940b3ee140deb0d85205c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency logRelease files / frozen_cub-0.3.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
| Download URL | frozen_cub-0.3.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 269.0 kB |
| Tags | CPython 3.12 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
93073617338ca392c4cecdbadc68ce5ce3115042eaff90c2da7e085a18de1bc3
|
|
BLAKE2b-256 checksum How to use checksums |
cbd5be590419655e9079d4755bf97c5cec6b2f6bff2115c04db322031527fc18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency logRelease files / frozen_cub-0.3.1-cp312-cp312-macosx_15_0_arm64.whl
| Download URL | frozen_cub-0.3.1-cp312-cp312-macosx_15_0_arm64.whl |
|---|---|
| Size | 59.8 kB |
| Tags | CPython 3.12 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0d8e2a1f10f2d945bab0fbc8e685a4667040ffc136aa5863a26ac345aa310bcc
|
|
BLAKE2b-256 checksum How to use checksums |
27aae0cf4718a38d3b6515b3d26872d372c0c4745abcd385a1156fc8bb68a275
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 9, 2026.
Transparency log