hydra.overlay.python.util.persistent_set module

Persistent ordered set, backed by a frozen frozenset.

Mirrors hydra.util.PersistentSet from Hydra-Java. Iteration is in sorted-element order. Implements collections.abc.Set so a PersistentSet IS a Set.

This implementation uses a native frozenset as the backing store. Native operations (in, |, &, -) are C-speed; the cost is full O(n) copies on update operations rather than O(log n) HAMT structure sharing.

Elements are ordered via hydra.overlay.python.util._compare.compare (natural < first, structural fallback for Hydra Term/Type and other complex values).

class hydra.overlay.python.util.persistent_set.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]