Last active
August 5, 2020 08:01
-
-
Save kzinmr/97c7a53b58de99815e4ac731de06b53b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ordered_uniq(seq): | |
seen = set() | |
seen_add = seen.add | |
return [x for x in seq if x not in seen and not seen_add(x)] | |
def ordered_uniq_unhashable(seq): | |
seq_s = [str(l) for l in seq] | |
return [eval(s) for s in ordered_uniq(seq_s)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from https://docs.python.org/2.6/library/itertools.html#recipes