Skip to main content

An immutable dictionary

Project description

frozendict is an immutable wrapper around dictionaries that implements the complete mapping interface. It can be used as a drop-in replacement for dictionaries where immutability is desired.

Of course, this is python, and you can still poke around the object’s internals if you want.

The frozendict constructor mimics dict, and all of the expected interfaces (iter, len, repr, hash, getitem) are provided. Note that a frozendict does not guarantee the immutability of its values, so the utility of hash method is restricted by usage.

The only difference is that the copy() method of frozendict takes variable keyword arguments, which will be present as key/value pairs in the new, immutable copy.

Example shell usage:

from frozendict import frozendict

fd = frozendict({ 'hello': 'World' })

print fd
# <frozendict {'hello': 'World'}>

print fd['hello']
# 'World'

print fd.copy(another='key/value')
# <frozendict {'hello': 'World', 'another': 'key/value'}>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

frozendict-1.2.tar.gz (2.6 kB view details)

Uploaded Source

File details

Details for the file frozendict-1.2.tar.gz.

File metadata

  • Download URL: frozendict-1.2.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for frozendict-1.2.tar.gz
Algorithm Hash digest
SHA256 774179f22db2ef8a106e9c38d4d1f8503864603db08de2e33be5b778230f6e45
MD5 483ce6ddfe68ca197bc123aaafebf9ab
BLAKE2b-256 4e55a12ded2c426a4d2bee73f88304c9c08ebbdbadb82569ebdd6a0c007cfd08

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