Comment

Mike Watkins

The coffee-corrected return for f13 (above) should be:

return [item for item in seq if item in uniq and not uniq.remove(item)]

Essentially the inverse of Dave Kirby's approach but just a hair faster for whatever reason set() only knows.

Replies

nn

My bet is on the memory allocation strategy. Adding to a set repeatedly allocates more memory for the set. I guess removing from the set does not deallocate memory until the end of the function.

Sven Berkvens-Matthijsse

The (small) disadvantage over Mike Watkins' version when compared to Dave Kirby's version is that Mike's version walks the given sequence twice. That means that it cannot be a generator, while Dave's version will handle generators just fine.