Registry / storage / constantdict

constantdict

JSON →
library2025.3pypypi✓ verified 85d ago

An immutable dict class providing a hashable, frozen dictionary that can be used as dict keys or in sets. Current version 2025.3, works with Python >=3.7. Released irregularly.

pip install constantdict
INSTALL
IMPORT
SIG · CONSTANTDICT
C
constantdict
storagepythonv2025.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

constantdict
from constantdict import constantdict
import constantdict
constantdict is a function, not a module; you need to import the function directly.

Create an immutable dict and demonstrate hashability.

from constantdict import constantdict d = constantdict({'a': 1, 'b': 2}) print(d['a']) # 1 print(hash(d)) # hashable
Debug
Known issues
gotchaconstantdict() expects a dict-like argument; passing multiple positional arguments raises TypeError.
fix
Use constantdict({'key': 'value'}) not constantdict('key', 'value').
affects: all
gotchaconstantdict is not an exact copy of dict; items() returns a tuple of tuples, not a view object.
fix
Access items with .items() which returns a tuple; if you need a dict_items view, convert: items = d.items() works as tuple, but not .viewitems().
affects: all
Errors
Common errors & fixes
AttributeError: module 'constantdict' has no attribute 'constantdict'
Importing the module instead of the function.
fix
Use 'from constantdict import constantdict'.
TypeError: constantdict() takes 1 positional argument but 2 were given
Passing multiple arguments to constantdict().
fix
Pass a single dict or iterable of pairs: constantdict({'a':1}) or constantdict([('a',1)]).
Upgrade
Version history
2025.3latest on PyPI · released Jul 21, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
30 hits · last 30 days
node
28
Resources
constantdict — pip install constantdict · libregistry