Closed FiV0 closed 1 year ago
There might be a way to make this better, I'm not sure, but given that sets have no deterministic ordering I don't think there's a good way to handle this in a general way. How do we know which set element to diff with which other set element?
If we generated multiple equivalent diffs, we could implement various heuristics for picking the "best" one, but that would add significant complexity and consume more resources, so not a quick project.
I agree that handling all the cases and ordering is probably hard (and expensive computewise). I just found it weird that in both cases above we are subdiffing {:foo 1}
and {:foo 1M}
, but end up with different diffs for that part.
Do you have a notion of distance for the diffs?
The reason you get a different result is that the seqs over these sets have different ordering
(seq #{{:foo 1M} {:bar 2}}) ;; => ({:foo 1M} {:bar 2})
(seq #{{:foo 1} {:bar 2}}) ;; => ({:bar 2} {:foo 1})
In certain cases the diff shows higher up in the hierarchy then expected. As an example:
I would have expected the diff to appear in the first case the same as in the second case.