David Mertz, Ph.D. writes:

 > This is exactly the problem solved by set difference. E.g.
 > `{a, b, c} - {a, c}`.
 > 
 > This operation is linear on the size of the removed set.

Couldn't it be linear on min(len(left), len(right))?  Ie,

    if len(left) < len(right):
        for elem in left:
            if elem in right:
               left.discard(elem)
    else:
        for elem in right:
            left.discard(elem)

The upper loop is probably only about half as fast as the lower (two
hashes needed), so maybe the length test could be tuned.

The whole idea is probably not worth it, I can't think of practical
use cases at a scale where it would matter.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/MOZZOH4ZMRKJ6X2BHY2RYMU7IHMJEFOF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to