itertools.intersect?

Carl Banks pavlovevidence at gmail.com
Thu Jun 11 06:06:50 CEST 2009


On Jun 10, 7:05 pm, Chris Rebert <c... at rebertia.com> wrote:
> On Wed, Jun 10, 2009 at 5:53 PM, Mensanator<mensana... at aol.com> wrote:
> > On Jun 10, 5:24 pm, David Wilson <d... at botanicus.net> wrote:
> >> Hi,
>
> >> During a fun coding session yesterday, I came across a problem that I
> >> thought was already solved by itertools, but on investigation it seems
> >> it isn't.
>
> >> The problem is simple: given one or more ordered sequences, return
> >> only the objects that appear in each sequence, without reading the
> >> whole set into memory. This is basically an SQL many-many join.
>
> > Why not use SQL?
>
> Agreed. I seem to recall the last person asking for such a function
> wanted to use it to combine SQL results.

Well if the source data is already in a sql database that would make
most sense, but if it isn't and since the iterator is pretty simple
I'd say just go with that.

Unless you have some other things happening downstream that would also
benefit from the source data being in a database, or something.


Carl Banks



More information about the Python-list mailing list