An immutable dict class.
Project description
constantdict
An immutable dictionary class for Python, implemented as a thin layer around dict
. It is often faster than other immutable dictionary implementations.
Usage
Install this package with:
$ pip install constantdict
Usage example:
from constantdict import constantdict
cd = constantdict({1: 2})
# constantdicts compare equal to dicts with the same items
assert cd == {1: 2}
# constantdicts are hashable, and their hashes are cached
print(hash(cd), cd)
# Attempting to modify the constantdict raises an AttributeError
try:
# Similar for pop(), popitem(), clear(), __ior__(), del, and setdefault()
cd[4] = 12
except AttributeError:
pass
Please also see the documentation.
License
MIT License.
Project details
Release history Release notifications | RSS feed
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 Distribution
File details
Details for the file constantdict-2024.1-py3-none-any.whl
.
File metadata
- Download URL: constantdict-2024.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cc0f2ba55d4b07ab17f95d13845950bc9e7671594a513b4a962644abb9c72c2 |
|
MD5 | ee5ff82142192b5ebaa69691c06a34f6 |
|
BLAKE2b-256 | 513d78e841f620f159391964970d503925777b45355fc2add4306aefe2ff2b4e |