How to use the frozendict.__init__.frozendict function in frozendict

To help you get started, we’ve selected a few frozendict examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github slezica / python-frozendict / frozendict / __init__.py View on Github external
def __len__(self):
        return len(self._dict)

    def __repr__(self):
        return '<%s %r>' % (self.__class__.__name__, self._dict)

    def __hash__(self):
        if self._hash is None:
            hashes = map(hash, self.items())
            self._hash = functools.reduce(operator.xor, hashes, 0)

        return self._hash


class FrozenOrderedDict(frozendict):
    """
    A frozendict subclass that maintains key order
    """

    dict_cls = collections.OrderedDict

frozendict

A simple immutable dictionary

LGPL-3.0
Latest version published 2 months ago

Package Health Score

82 / 100
Full package analysis

Similar packages