projects
/
python_utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
393ce08
)
Dedup a list w/ a set.
author
Scott Gasch
<
[email protected]
>
Wed, 22 Sep 2021 01:25:17 +0000
(18:25 -0700)
committer
Scott Gasch
<
[email protected]
>
Wed, 22 Sep 2021 01:25:17 +0000
(18:25 -0700)
list_utils.py
patch
|
blob
|
history
diff --git
a/list_utils.py
b/list_utils.py
index 533317eb6da71f44a4f8b3c338505c053c460c0b..c04a5343be656b62a07fc0d6af8b9b9880b5feda 100644
(file)
--- 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()