This made me very curious about efficient set union. Here's a pretty straightforward set union in python:
def set_union(coll1, coll2):
result = set()
for item in coll1:
result.add(item)
for item in coll2:
result.add(item)
return result
Apparently that isn't the efficient way to do it -- what is?Regardless, the article strongly suggests that one of the two arguments to clojure.set's union does offer fast set membership, since only the second argument is permitted to not be a set.