{"comment":{"created_at":"2011-10-07T21:00:25Z","body":"By the way, random is useless, as you said, because everything relies on canonical arg ordering.  But if the ordering were random, but still deterministic throughout that session, that would be useful.  In other words, if we could apply some random, but fixed, hash function as the sort key, then this would let us easily weed out these issues where the result depends on hashing.\r\n\r\nPerhaps we could just add a random number (defaulting to 0 if random mode is off) to the hashable_content, which would then essentially randomize the hash.","updated_at":"2011-10-07T21:00:25Z","url":"https://api.github.com/repos/sympy/sympy/issues/comments/2328210","id":2328210,"user":{"avatar_url":"https://secure.gravatar.com/avatar/0383e4cae325f65a1bbd906be4be2276?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/asmeurer","id":71486,"login":"asmeurer"}},"action":"created","issue":{"number":637,"created_at":"2011-10-07T20:50:06Z","pull_request":{"diff_url":"https://github.com/sympy/sympy/pull/637.diff","patch_url":"https://github.com/sympy/sympy/pull/637.patch","html_url":"https://github.com/sympy/sympy/pull/637"},"body":"Now both `sort_key()` and `default_sort_key()` return only comparable objects (tuples, strings, numbers). I also added a new switch `-A` to isympy, test and doctest, which allows to choose sorting algorithm for `Add.args`: `hash`, `random` or `sort_key`. `hash` is the default. `random` doesn't really give much, because almost whole SymPy fails with this. But `sort_key` is very useful and allows to reproduce problems that we have under PyPy (for example). If you run `bin/test -A sort_key`, then all tests pass besides well know `piecewise_fold`. There are also doctest failures if your run `bin/doctest -A sort_key`, but you will see that this is only a coincidence that they pass with `-A hash`. SymPy is about 5% slower when running tests with `-A sort_key`. It should be possible to reduce this by using customized caching for `sort_key()` (as we use for `__hash__()`).","comments":2,"title":"Robustified sort_key() and default_sort_key()","updated_at":"2011-10-07T21:00:25Z","url":"https://api.github.com/repos/sympy/sympy/issues/637","id":1848782,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/89164142ec718a76a7e04481062acaea?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/mattpap","id":27475,"login":"mattpap"},"html_url":"https://github.com/sympy/sympy/issues/637","labels":[],"state":"open"},"legacy":{"issue_id":1848782,"comment_id":2328210}}