intersection of 2 list of pairs

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Tue Feb 22 16:53:43 EST 2005


The use of frozenset can okay when sub-sequences are longer, but for
this problem it's slow, and anyway there are situations of repeated
data like this that have to be considered:

frozenset( ('a', 'a') )
==>
frozenset(['a'])

For Py2.4 the faster and better solution seems Peter Otten one.
James Stroud solution is O(n^2) and it can become slow for long
lists...

Bear hugs,
Bearophile




More information about the Python-list mailing list