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:
-
as_list–Convert iterable to list, unless it's already a list.
-
chunk_list–Yield successive chunk_size chunks from lst.
-
common_prefix–Find the longest prefix common to all items.
-
flatten_2d_lists–Flatten a list of lists to a single list.
-
full_groupby–Unlike
itertools.groupby, groups are not broken by -
swap_dict_values–Swap values between two keys.
LazyDict ¶
Bases: Mapping[str, _V], Generic[_V]
Evaluates dictionary items only when they are accessed.
Adapted from: https://stackoverflow.com/a/47212782/5082708
Source code in vllm/utils/collection_utils.py
as_list(maybe_list) ¶
chunk_list(lst, chunk_size) ¶
common_prefix(items) ¶
Find the longest prefix common to all items.
Source code in vllm/utils/collection_utils.py
flatten_2d_lists(lists) ¶
full_groupby(values, *, key) ¶
Unlike itertools.groupby, groups are not broken by non-contiguous data.
Source code in vllm/utils/collection_utils.py
swap_dict_values(obj, key1, key2) ¶
Swap values between two keys.