{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/11757","repository_url":"https://api.github.com/repos/sympy/sympy","labels_url":"https://api.github.com/repos/sympy/sympy/issues/11757/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/11757/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/11757/events","html_url":"https://github.com/sympy/sympy/issues/11757","id":184668442,"number":11757,"title":"Instantiating Piecewise((a, Eq(x, y)), (b, True)) is extremely slow","user":{"login":"rlamy","id":142362,"avatar_url":"https://avatars.githubusercontent.com/u/142362?v=3","gravatar_id":"","url":"https://api.github.com/users/rlamy","html_url":"https://github.com/rlamy","followers_url":"https://api.github.com/users/rlamy/followers","following_url":"https://api.github.com/users/rlamy/following{/other_user}","gists_url":"https://api.github.com/users/rlamy/gists{/gist_id}","starred_url":"https://api.github.com/users/rlamy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlamy/subscriptions","organizations_url":"https://api.github.com/users/rlamy/orgs","repos_url":"https://api.github.com/users/rlamy/repos","events_url":"https://api.github.com/users/rlamy/events{/privacy}","received_events_url":"https://api.github.com/users/rlamy/received_events","type":"User","site_admin":false},"labels":[{"id":141290597,"url":"https://api.github.com/repos/sympy/sympy/labels/Performance","name":"Performance","color":"fbca04","default":false},{"id":230277725,"url":"https://api.github.com/repos/sympy/sympy/labels/solvers.dsolve","name":"solvers.dsolve","color":"0000FF","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-23T03:06:01Z","updated_at":"2016-11-04T04:41:12Z","closed_at":null,"body":"Another issue (after #11717) found by looking at the [dsolve() benchmark](https://github.com/sympy/sympy_benchmarks/blob/master/benchmarks/dsolve.py): constructing Piecewise instances of the form `Piecewise((a, Eq(x, y)), (b, True))` takes way too long.\n\nTo demonstrate the problem, here's [a simple benchmark](https://gist.github.com/rlamy/810ee71df6a6b2d426e63386637742b6). I get timings of ~45 ms per instance creation on CPython 2.7, which is orders of magnitude more than the creation of such a simple object should take. \n\n[Profiling this under vmprof](http://vmprof.com/#/0fb1992184c7df9d46697a2c35307e12) shows that the vast majority of the time is spent in `nsimplify()` which is called by `random_complex_number()`.\n\nThere are actually two issues here:\n- `random_complex_number(..., rational=True)` shouldn't call `nsimplify()`\n- The constructor for Piecewise should not be attempting such complicated calculations in the first place.\n"},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/258343672","html_url":"https://github.com/sympy/sympy/issues/11757#issuecomment-258343672","issue_url":"https://api.github.com/repos/sympy/sympy/issues/11757","id":258343672,"user":{"login":"asmeurer","id":71486,"avatar_url":"https://avatars.githubusercontent.com/u/71486?v=3","gravatar_id":"","url":"https://api.github.com/users/asmeurer","html_url":"https://github.com/asmeurer","followers_url":"https://api.github.com/users/asmeurer/followers","following_url":"https://api.github.com/users/asmeurer/following{/other_user}","gists_url":"https://api.github.com/users/asmeurer/gists{/gist_id}","starred_url":"https://api.github.com/users/asmeurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmeurer/subscriptions","organizations_url":"https://api.github.com/users/asmeurer/orgs","repos_url":"https://api.github.com/users/asmeurer/repos","events_url":"https://api.github.com/users/asmeurer/events{/privacy}","received_events_url":"https://api.github.com/users/asmeurer/received_events","type":"User","site_admin":false},"created_at":"2016-11-04T04:41:12Z","updated_at":"2016-11-04T04:41:12Z","body":"Should this be closed?"}}
{"actor":{"display_login":"asmeurer"}}