[Tutor] Lists...

Andrew Wilkins toodles@yifan.net
Thu, 31 May 2001 16:21:10 +0800


Thanks very much D-Man, Sam, Remco and Roeland, this has been very helpful!

Andrew Wilkins

> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> Remco Gerlich
> Sent: Thursday, 31 May 2001 3:32 PM
> To: tutor@python.org
> Subject: Re: [Tutor] Lists...
>
>
> 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
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>