hydra.overlay.python.util package
Submodules
- hydra.overlay.python.util.cons_list module
ConsListConsList.concat()ConsList.cons()ConsList.drop()ConsList.empty()ConsList.filter()ConsList.foldl()ConsList.foldr()ConsList.from_iterable()ConsList.headConsList.init()ConsList.is_empty()ConsList.last()ConsList.map()ConsList.of()ConsList.reverse()ConsList.singleton()ConsList.tailConsList.take()
- hydra.overlay.python.util.lazy module
- hydra.overlay.python.util.persistent_map module
PersistentMapPersistentMap.alter()PersistentMap.bimap()PersistentMap.contains_key()PersistentMap.delete()PersistentMap.empty()PersistentMap.filter()PersistentMap.filter_with_key()PersistentMap.fold()PersistentMap.from_mapping()PersistentMap.from_pairs()PersistentMap.insert()PersistentMap.is_empty()PersistentMap.items()PersistentMap.keys()PersistentMap.keys_list()PersistentMap.lookup()PersistentMap.map_keys()PersistentMap.map_values()PersistentMap.of_entries()PersistentMap.singleton()PersistentMap.to_list()PersistentMap.union()PersistentMap.values()PersistentMap.values_list()
- hydra.overlay.python.util.persistent_set module
PersistentSetPersistentSet.delete()PersistentSet.difference()PersistentSet.empty()PersistentSet.filter()PersistentSet.from_iterable()PersistentSet.insert()PersistentSet.intersection()PersistentSet.is_empty()PersistentSet.map()PersistentSet.member()PersistentSet.of()PersistentSet.singleton()PersistentSet.to_list()PersistentSet.union()PersistentSet.unions()
Module contents
Internal collection classes and utilities for Hydra-Python.
Mirrors Hydra-Java’s hydra.util package. Persistent (structurally-shared) collection classes that satisfy collections.abc.{Sequence, Mapping, Set} so they can be used wherever the abstract types are accepted, while providing sub-linear updates suitable for inference-style workloads.
- class hydra.overlay.python.util.ConsList(_inner: tuple[Any, ...] | None = None, _start: int = 0, *, _internal: bool = False)
Bases:
Sequence[T],Generic[T]A persistent (immutable) sequence backed by a native
tupleplus offset.Construct via
ConsList.empty(),ConsList.cons(x, xs),ConsList.singleton(x),ConsList.of(...), orConsList.from_iterable(...). Direct__init__is gated.- foldl(f: Callable[[R, T], R], initial: R) R
- foldr(f: Callable[[T, R], R], initial: R) R
- property head: T
- is_empty() bool
- last() T
- class hydra.overlay.python.util.Lazy(fn: Callable[[], T])
Bases:
Generic[T]A one-shot memoizer for a zero-argument computation.
- get() T
- class hydra.overlay.python.util.PersistentMap(_inner: dict[Any, Any] | None = None, *, _internal: bool = False)
Bases:
Mapping[K,V],Generic[K,V]A persistent (immutable) map backed by a frozen native
dict.Construct via
PersistentMap.empty(),PersistentMap.singleton(k, v),PersistentMap.from_pairs(...), orPersistentMap.from_mapping(...).- alter(f: Callable[[Any], Any], key: K) PersistentMap[K, V]
- bimap(fk: Callable[[K], K2], fv: Callable[[V], V2]) PersistentMap[K2, V2]
- contains_key(key: K) bool
- delete(key: K) PersistentMap[K, V]
- static empty() PersistentMap[Any, Any]
- filter(predicate: Callable[[V], bool]) PersistentMap[K, V]
- filter_with_key(predicate: Callable[[K, V], bool]) PersistentMap[K, V]
- fold(f: Callable[[R, K, V], R], initial: R) R
- static from_mapping(source: Mapping[K, V]) PersistentMap[K, V]
- static from_pairs(pairs: Iterable[tuple[K, V]]) PersistentMap[K, V]
- insert(key: K, value: V) PersistentMap[K, V]
- is_empty() bool
- items() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D's keys
- keys_list() list[K]
- lookup(key: K) Any | None
- map_keys(f: Callable[[K], K2]) PersistentMap[K2, V]
- map_values(f: Callable[[V], V2]) PersistentMap[K, V2]
- static of_entries(*entries: tuple[K, V]) PersistentMap[K, V]
- static singleton(key: K, value: V) PersistentMap[K, V]
- to_list() list[tuple[K, V]]
- union(other: PersistentMap[K, V]) PersistentMap[K, V]
Left-biased union: entries in
selfwin on key collision.Implemented as
{**other._inner, **self._inner}: build other first, then overlay self → self values overwrite other on collision (left-biased). Pure C-speed, no Python-level loop.
- values() an object providing a view on D's values
- values_list() list[V]
- class hydra.overlay.python.util.PersistentSet(_inner: frozenset[Any] | None = None, *, _internal: bool = False)
Bases:
Set[T],Generic[T]A persistent (immutable) ordered set backed by
frozenset.- delete(element: T) PersistentSet[T]
- difference(other: PersistentSet[T]) PersistentSet[T]
- static empty() PersistentSet[Any]
- filter(predicate: Callable[[T], bool]) PersistentSet[T]
- static from_iterable(values: Iterable[T]) PersistentSet[T]
- insert(element: T) PersistentSet[T]
- intersection(other: PersistentSet[T]) PersistentSet[T]
- is_empty() bool
- map(f: Callable[[T], U]) PersistentSet[U]
- member(element: T) bool
- static of(*elements: T) PersistentSet[T]
- static singleton(value: T) PersistentSet[T]
- to_list() list[T]
- union(other: PersistentSet[T]) PersistentSet[T]
- static unions(sets: Iterable[PersistentSet[T]]) PersistentSet[T]