Pythonic way of saying 'at least one of a, b, or c is in some_list'
Paul Rubin
no.email at nospam.invalid
Fri Oct 29 01:50:02 EDT 2010
John Nagle <nagle at animats.com> writes:
> d1 = set('monday','tuesday')
> days_off = set('saturday','sunday')
> if not d1.isdisjoint(days_off) :...
> This is cheaper than intersection, since it doesn't have to
> allocate and construct a set. It just tests whether any element in the
> smaller of the two sets is in the larger one.
I wonder what the complexity is, since the simplest implementation using
the dict-like features of sets is quadratic. There is of course an
obvious n log n implementation involving sorting.
More information about the Python-list
mailing list