Skip to content

deduplicate_list

deduplicate_list(this_list)

Custom replacement for set(this_list), when items are non-hashable.

Source code in fractal_server/app/runner/v2/deduplicate_list.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def deduplicate_list(
    this_list: list[T],
) -> list[T]:
    """
    Custom replacement for `set(this_list)`, when items are non-hashable.
    """
    new_list_dict = []
    new_list_objs = []
    for this_obj in this_list:
        this_dict = this_obj.dict()
        if this_dict not in new_list_dict:
            new_list_dict.append(this_dict)
            new_list_objs.append(this_obj)
    return new_list_objs