06.06.22 10:51, Stephen J. Turnbull пише:
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.
It is close to the current implementation:
if len(left) < len(right)//8:
right = left & right
for elem in left:
if elem in right:
left.discard(elem)
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/OGOMGS4353C34REIWQWWUNPF6LAX655C/
Code of Conduct: http://python.org/psf/codeofconduct/