Empty sets are always identical (apparently)
(identical? #{} #{}) ;=> true
But when we add values this changes
(identical? #{1} #{1}) ;=> false
What about results of operations?
(def set1 (set (range 100)))
(def set2 (set (range 100)))
(identical? set1 set2) ;=> false, expected given above
(def union (clojure.set/union set1 set2))
(identical? union set1) ;=> true, ok cool!
(identical? union set2) ;=> false, too bad
What does this mean? It means that if we generate sets without thought we can easily use more memory that needed. This has implications for yes, memory usage, but also for gc and thus cpu.
How can we prevent this waste? By using identical? at the right places and if this is too expensive (for large sets) we could use signatures and lookup maps.