On Wed, 04 Apr 2007 15:56:34 +0200, Hendrik van Rooyen wrote: > Now how would one do it and preserve the original order? > This apparently simple problem is surprisingly FOS... > But list comprehension to the rescue : > >>>>[x for x in duplist if duplist.count(x) == 1] > ['haha', 5, 6] >>>> > > *shakes head* duh... why does it take so long?
Because you are using Shlemiel the painter's algorithm: http://www.joelonsoftware.com/articles/fog0000000319.html Each time you call duplist.count(), you go back to the beginning of the list and walk the entire list. You end up walking the list over and over and over again. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list