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.0.tar.gz (2.6 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for frozendict-1.0.tar.gz
Algorithm Hash digest
SHA256 4852b8d74173f69bfaaca2dc77b69b0ae85ceddbead80d1954aa250d90e66f32
MD5 6d4ab55e12244bc0400eb9d4d36bdb18
BLAKE2b-256 41015cb4c704130b8e3d6ec60a68402fad0e82e6760c4beaa698ff80023639dd

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