Skip to main content

An immutable dict class.

Project description

PyPI version Doc Status License PyPI - Downloads

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


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

constantdict-2024.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file constantdict-2024.1-py3-none-any.whl.

File metadata

File hashes

Hashes for constantdict-2024.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7cc0f2ba55d4b07ab17f95d13845950bc9e7671594a513b4a962644abb9c72c2
MD5 ee5ff82142192b5ebaa69691c06a34f6
BLAKE2b-256 513d78e841f620f159391964970d503925777b45355fc2add4306aefe2ff2b4e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page