Most efficient solution?

Alexandre Fayolle alf at
Mon Jul 16 17:38:46 CEST 2001

On 16 Jul 2001 11:06:41 -0400, Alex <new_name at> wrote:
>> C = {}
>> for item in B:
>>     C[item] = 1
>> A = filter(C.get, A)
>I guess that'll drop some elements from A that are in B but evaluate to
>false, though.

I'm pretty sure this will work, though I've not tested. C.get(item) will
return None (thus false) if item was not in B, and 1 (thus true) if item
was in B. You should definitely give a try to this version.

Alexandre Fayolle
LOGILAB, Paris (France).
Narval, the first software agent available as free software (GPL).

More information about the Python-list mailing list