[Tutor] Lists...
Remco Gerlich
scarblac@pino.selwerd.nl
Thu, 31 May 2001 09:32:02 +0200
On 0, Roeland Rengelink <r.b.rigilink@chello.nl> wrote:
> As you can see, Remco's version is fastest (staying at less than .1 sec
> for two
> 10k lists). I minor quibble would be that that method doesn't detect a 0
> that's in both lists.
It does. dict.has_key(0) is 1 in that case, and the filter puts it in the
result.
> intersect3 is the only reasonable thing I could come up with that
> doesn't use dicts. It's also scales linearly, but it's 4 times slower
> (and took 100 times longer to write, it had a non-obvious bug) than
> intersect2. It may be usefull if your list elements are non-hashable
> (can't be dictionary keys).
Yes. Sorting them hadn't occurred to me yet.
--
Remco Gerlich