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 Python's builtin dict class. 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(), del, and setdefault()
    cd[4] = 12
except AttributeError:
    pass

Please also see the documentation, as well as the examples in the examples/ directory.

References

Other packages

PEPs

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

If you're not sure about the file name format, learn more about wheel file names.

constantdict-2024.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: constantdict-2024.3-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for constantdict-2024.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b9ad49ac916620c8782afc5d60bdba979994cad908868767e9b05c833b5b2914
MD5 ecf43b6954d9b425e35007d0b72fdb0f
BLAKE2b-256 afd7a7fb7591a6e6e2b3399d3c2b6424882c7812be874ac0c8957b7e6f61464b

See more details on using hashes here.

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