Jani Tiainen <[EMAIL PROTECTED]> writes:
> for addr in list_external:
> if addr not in list_internal:
> addr.status = 1 # New address
>
> But in my case running that loop takes about 10 minutes. What I am
> doing wrong?
The nested loop takes time proportional to the product of the number
of elements in the loops. To avoid it, convert the inner loop to a
set, which can be looked up in constant time:
internal = set(list_internal)
for addr in list_external:
if addr in internal:
addr.status = 1
--
http://mail.python.org/mailman/listinfo/python-list