perf: replace repr-based sorting with str-based and enforce sorted JSON keys #11
DS-Review completed
This PR improves performance by replacing repr with str for sorting keys/elements in hashing and adding sort_keys=True to JSON serialization. However, the change introduces a critical determinism bug for mixed-type collections (e.g., sets containing both 1 and '1') where str() returns identical strings, causing non-deterministic hashing. It also changes the canonical representation for string values, silently invalidating all existing caches. The PR description incorrectly claims str() and repr() return identical strings for all relevant types. Test coverage only includes homogeneous collections, missing the mixed-type cases that could expose the bug. The JSON serialization change is safe and beneficial. The recommended changes are to revert to repr for sorting, or clearly document and guard against mixed-type inputs, and correct the PR description. Add tests for mixed-type collections to prevent regressions.