frozendict

Frozen dictionary and shared hashing helpers for PySATL CPD.

class pysatl_cpd.typedefs.frozendict.frozendict(**kwargs)[source]

Bases: Mapping, Generic

Immutable dictionary with stable hashing.

Parameters:

**kwargs (TypeVar(V_co)) – Key-value pairs to populate the dictionary.

__init__(**kwargs)[source]
Parameters:
Return type:

None

classmethod from_mapping(data)[source]

Create a frozen dictionary from an arbitrary mapping.

Parameters:

data (Mapping[TypeVar(K), TypeVar(V_co)]) – Source mapping to copy.

Returns:

A new frozen dictionary with the same items.

Return type:

frozendict[TypeVar(K), TypeVar(V_co)]

__getitem__(key)[source]

Return the value for key.

Parameters:

key (TypeVar(K)) – The key to look up.

Returns:

The value associated with the key.

Return type:

TypeVar(V_co)

__iter__()[source]

Iterate over dictionary keys.

Return type:

Iterator[TypeVar(K)]

__len__()[source]

Return the number of items.

Return type:

int

__hash__()[source]

Return the pre-computed hash.

Return type:

int

__repr__()[source]

Return a reproducible string representation.

Return type:

str

__eq__(other)[source]

Compare with another mapping for item-wise equality.

Return type:

bool

Parameters:

other (object)

__setattr__(name, value)[source]

Block attribute mutation; instances are immutable.

Return type:

None

Parameters:
__delattr__(name)[source]

Block attribute deletion; instances are immutable.

Return type:

None

Parameters:

name (str)

__getstate__()[source]

Return pickling state as a plain dict.

Return type:

dict

__setstate__(state)[source]

Restore pickling state.

Return type:

None

Parameters:

state (dict)

pysatl_cpd.typedefs.frozendict.make_hashable(value)[source]

Recursively normalize common mutable containers into hashable values.

Return type:

Hashable

Parameters:

value (Any)

pysatl_cpd.typedefs.frozendict.stable_hash(value)[source]

Return a deterministic Python-hash value for a normalized object.

Return type:

int

Parameters:

value (object)