efficient list merging

Emile van Sebille emile at fenx.com
Tue Sep 3 21:36:39 EDT 2002

"Peter Saffrey" <theoryboy at my-deja.com> wrote in message
news:ced73313.0209031012.13624f3 at posting.google.com...
> I have two lists of lists of strings which I would like to merge
> efficiently without repeats.

I like sets in current cvs:

Python 2.3a0 (#29, Aug 31 2002, 19:16:08) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sets
>>> s1 = sets.Set('abcdefg')
>>> s2 = sets.Set('efghijk')
>>> s1^s2
Set(['a', 'c', 'b', 'd', 'i', 'h', 'k', 'j'])
>>> s1|s2
Set(['a', 'c', 'b', 'e', 'd', 'g', 'f', 'i', 'h', 'k', 'j'])
>>> s1&s2
Set(['e', 'g', 'f'])

Emile van Sebille
emile at fenx.com

More information about the Python-list mailing list