diff options
| author | Scott Gasch <[email protected]> | 2021-09-21 18:25:17 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2021-09-21 18:25:17 -0700 |
| commit | 946279b8b220d9dffe3b47b3bda8ba9e48ccb25a (patch) | |
| tree | a4892ee4b00fed2593b428dc0f1f66df8ceaa251 /list_utils.py | |
| parent | 393ce08bb176a44ceb598c2e173f274c39833561 (diff) | |
Dedup a list w/ a set.
Diffstat (limited to 'list_utils.py')
| -rw-r--r-- | list_utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/list_utils.py b/list_utils.py index 533317e..c04a534 100644 --- a/list_utils.py +++ b/list_utils.py @@ -86,6 +86,17 @@ def least_common_item(lst: List[Any]) -> Any: return population_counts(lst).most_common()[-1][0] +def dedup_list(lst: List[Any]) -> List[Any]: + """ + Remove duplicates from the list performantly. + + >>> dedup_list([1, 2, 1, 3, 3, 4, 2, 3, 4, 5, 1]) + [1, 2, 3, 4, 5] + + """ + return list(set(lst)) + + if __name__ == '__main__': import doctest doctest.testmod() |
