brainstate.util.freeze#
- brainstate.util.freeze(x)[source]#
Convert a mapping to a FrozenDict.
- Parameters:
x (
Mapping[TypeVar(K),TypeVar(V)]) – A mapping (dict, FrozenDict, etc.) to freeze.- Returns:
An immutable FrozenDict.
- Return type:
FrozenDict[TypeVar(K),TypeVar(V)]
See also
unfreezeConvert a FrozenDict to a regular dict.
FrozenDictThe immutable dictionary class.
Examples
>>> from brainstate.util import freeze >>> d = {'a': 1, 'b': {'c': 2}} >>> fd = freeze(d) >>> isinstance(fd, FrozenDict) True >>> isinstance(fd['b'], FrozenDict) # Nested dicts are frozen True