Skip to content

Instantly share code, notes, and snippets.

@tenfyzhong
Created August 12, 2018 09:38
Show Gist options
  • Save tenfyzhong/c2b836872b8dea0e45da416771225110 to your computer and use it in GitHub Desktop.
Save tenfyzhong/c2b836872b8dea0e45da416771225110 to your computer and use it in GitHub Desktop.
remove duplications
def dedupe(items, key=None):
seen = set()
for item in items:
val = item if key is None else key(item)
if val not in seen:
yield item
seen.add(val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment