[Tutor] Best method for filtering lists in lists...

Alan Gauld alan.gauld at btinternet.com
Sun Dec 17 01:00:54 CET 2006


"Roel Schroeven" <rschroev_nospam_ml at fastmail.fm> wrote

>> In that case put the inner lists in a Set. That will eliminate
>> duplicates.
>
> That won't work: list objects are unhashable so you can't put them 
> in a
> set. You'll have to convert them to tuples first.

Hmm, I took that a self evident but I guess maybe it wasn't...

As for Luke's point about the speed of conversion, I'm not
sure how that would stack up. I have a gut feel that it might
be faster than trying to compare the lists element by
element, that sounds like an algebraic expansion with list
size to me, a hashed set sounds like it should be faster.
But as with all such things, if speed matters: measure
and profile it.

Alan G. 




More information about the Tutor mailing list