Terry Reedy wrote:
The straightforward code
if a in L and b in L and c not in L and d not in L
scans the list 4 times.
of course for a single scan one can setify the list and write
S=set(L)
if a in S and b in S and c not in S and d not in S
or even, I guess, something like
{a,b} <= S and not S & {c,d}
also, I suppose that in some settings a,b,c,d could be made to belong to a class
that has defined eg
__nonzero__ = __bool__ = S.__contains__
so that the if statement would become
if a and b and not c and not d
btw, did anybody ask the OP which if any of A,B,C,D otoh and L otoh would vary
fastest ?
Whatever, BB
--
http://mail.python.org/mailman/listinfo/python-list