Skip to content

vllm.utils.collection_utils

Contains helpers that are applied to collections.

This is similar in concept to the collections module.

Classes:

  • LazyDict –

    Evaluates dictionary items only when they are accessed.

Functions:

LazyDict

Bases: Mapping[str, _V], Generic[_V]

Evaluates dictionary items only when they are accessed.

Adapted from: https://stackoverflow.com/a/47212782/5082708

as_list(maybe_list)

Convert iterable to list, unless it's already a list.

chunk_list(lst, chunk_size)

Yield successive chunk_size chunks from lst.

common_prefix(items)

common_prefix(items: Sequence[str]) -> str
common_prefix(items: Sequence[Sequence[T]]) -> Sequence[T]

Find the longest prefix common to all items.

flatten_2d_lists(lists)

Flatten a list of lists to a single list.

full_groupby(values, *, key)

Unlike itertools.groupby, groups are not broken by non-contiguous data.

is_list_of_numbers(value)

Check every item is an int or finite float, excluding booleans.