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.
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.
Comment
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.
Parent comment
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.