Clojure uses set union on key seqs


  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Patch:

Description, on line 118, defines:

(diff-similar [a b]
  (diff-associative a b (set/union (keys a) (keys b))))

Since keys returns a key seq, this seems like an error. clojure.set/union has strange and inconsistent behavior with regard to non-sets, and in this case the two key seqs are concatenated. Based on a cursory benchmark, it seems that this bug is a slight performance gain when the maps have no common keys, and a significant performance loss when the maps have the same keys. The results are still correct because of the merging reduce in diff-associative.

The patch is easy (just call set on each key seq).


Andy Fingerhut made changes -
Field Original Value New Value
Attachment clj-1087-diff-perf-enhance-patch-v1.txt [ 11562 ]
Andy Fingerhut made changes -
Issue Type Defect [ 1 ] Enhancement [ 4 ]
Patch Code [ 10001 ]
Alex Miller made changes -
Labels bug performance performance
Andy Fingerhut made changes -
Labels performance checkargs performance


  • Assignee:
    Tom Jack
Vote (1)
Watch (2)


  • Created: