bag.util.immutable

This module defines various immutable and hashable data types.

Module Contents

Classes

ImmutableList

An immutable homogeneous list.

ImmutableSortedDict

An immutable dictionary with sorted keys.

Functions

combine_hash(→ int)

Combine the two given hash values.

to_immutable(→ ImmutableType)

Convert the given Python object into an immutable type.

update_recursive(→ None)

Attributes

T

U

ImmutableType

Param

bag.util.immutable.T[source]
bag.util.immutable.U[source]
bag.util.immutable.ImmutableType[source]
bag.util.immutable.combine_hash(a: int, b: int) int[source]

Combine the two given hash values.

Parameter

aint

the first hash value.

bint

the second hash value.

returns:

hash – the combined hash value.

rtype:

int

class bag.util.immutable.ImmutableList(values: Optional[collections.Sequence[T]] = None)[source]

Bases: collections.Hashable, collections.Sequence, Generic[T]

An immutable homogeneous list.

classmethod sequence_equal(a: collections.Sequence[T], b: collections.Sequence[T]) bool[source]
__repr__() str[source]

Return repr(self).

__eq__(other: Any) bool[source]

Return self==value.

__hash__() int[source]

Return hash(self).

__bool__() bool[source]
__len__() int[source]
__iter__() Iterable[T][source]
__getitem__(idx: int) T[source]
__getitem__(idx: slice) ImmutableList[T]
__contains__(val: Any) bool[source]
index(*args, **kwargs) int[source]
to_list() List[Any][source]
to_yaml() List[Any][source]
class bag.util.immutable.ImmutableSortedDict(table: Optional[collections.Mapping[T, Any]] = None)[source]

Bases: collections.Hashable, collections.Mapping, Generic[T, U]

An immutable dictionary with sorted keys.

__repr__() str[source]

Return repr(self).

__eq__(other: Any) bool[source]

Return self==value.

__hash__() int[source]

Return hash(self).

__bool__() bool[source]
__len__() int[source]
__iter__() Iterable[T][source]
__contains__(item: Any) bool[source]
__getitem__(item: T) U[source]
get(item: T, default: Optional[U] = None) Optional[U][source]
keys() Iterable[T][source]
values() Iterable[U][source]
items() Iterable[Tuple[T, U]][source]
copy(append: Optional[Dict[T, Any]] = None, remove: Optional[collections.Sequence[T]] = None) ImmutableSortedDict[T, U][source]
to_dict() Dict[T, U][source]
to_yaml() Dict[str, Any][source]
bag.util.immutable.Param[source]
bag.util.immutable.to_immutable(obj: Any) ImmutableType[source]

Convert the given Python object into an immutable type.

bag.util.immutable.update_recursive(table, value, *args) None[source]