Eliminating duplicates entries from a list efficiently

Roger Binns rogerb at rogerbinns.com
Sat Jul 3 04:33:56 CEST 2004


Paul wrote:
> Can anyone suggest an efficient way to eliminate duplicate entries
> in a list?  The naive approach below works fine,

The less naive approach to go to the Python cookbook which contains
lots of recipes for doing all sorts of things, commented on and
improved by the community.

The starting page is:

  http://aspn.activestate.com/ASPN/Python/Cookbook/

For example here is a recipe by one Tim Peters that shows how to
do it, including all the subtle cases you didn't even realise
existed.

  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560

I would highly recommend getting the Python Cookbook dead tree
version.

Roger





More information about the Python-list mailing list