Popular recipes by Tim Peters http://code.activestate.com/recipes/users/98361/2001-04-06T00:54:02-07:00ActiveState Code RecipesRemove duplicates from a sequence (Python)
2001-04-06T00:54:02-07:00Tim Petershttp://code.activestate.com/recipes/users/98361/http://code.activestate.com/recipes/52560-remove-duplicates-from-a-sequence/
<p style="color: grey">
Python
recipe 52560
by <a href="/recipes/users/98361/">Tim Peters</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
</p>
<p>The fastest way to remove duplicates from a sequence depends on some pretty subtle properties of the sequence elements, such as whether they're hashable, and whether they support full comparisons. The unique() function tries three methods, from fastest to slowest, letting runtime exceptions pick the best method available for the sequence at hand.</p>