{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/13401","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/13401/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/13401/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/13401/events","html_url":"https://github.com/JuliaLang/julia/issues/13401","id":109294231,"number":13401,"title":"Poor performance for linspace","user":{"login":"stevengj","id":2913679,"avatar_url":"https://avatars.githubusercontent.com/u/2913679?v=3","gravatar_id":"","url":"https://api.github.com/users/stevengj","html_url":"https://github.com/stevengj","followers_url":"https://api.github.com/users/stevengj/followers","following_url":"https://api.github.com/users/stevengj/following{/other_user}","gists_url":"https://api.github.com/users/stevengj/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengj/subscriptions","organizations_url":"https://api.github.com/users/stevengj/orgs","repos_url":"https://api.github.com/users/stevengj/repos","events_url":"https://api.github.com/users/stevengj/events{/privacy}","received_events_url":"https://api.github.com/users/stevengj/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/performance","name":"performance","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-10-01T12:59:34Z","updated_at":"2015-10-01T19:27:39Z","closed_at":null,"body":"This seems odd to me:\r\n```\r\njulia> f(X) = [sin(x) + x^2 - 3 for x in X]\r\n       x = linspace(0,1,10^7)\r\n       @time f(x);\r\n  0.286351 seconds (6 allocations: 76.294 MB, 0.21% gc time)\r\n\r\njulia> x = collect(x)\r\n       @time f(x);\r\n  0.085037 seconds (6 allocations: 76.294 MB, 5.49% gc time)\r\n```\r\nI can understand why e.g. `x.^2` might be slower for a linspace, since the computation is so cheap compared to computing the elements of the linspace on the fly, but I don't understand why a more complex operation like this, in a comprehension where the elements are calculated only once per computation, is so much slower.\r\n\r\nSee also the [mailing list discussion](https://groups.google.com/d/msg/julia-users/qPqgJS-usrU/Hu40_tOlDQAJ)."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/144823392","html_url":"https://github.com/JuliaLang/julia/issues/13401#issuecomment-144823392","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/13401","id":144823392,"user":{"login":"timholy","id":1525481,"avatar_url":"https://avatars.githubusercontent.com/u/1525481?v=3","gravatar_id":"","url":"https://api.github.com/users/timholy","html_url":"https://github.com/timholy","followers_url":"https://api.github.com/users/timholy/followers","following_url":"https://api.github.com/users/timholy/following{/other_user}","gists_url":"https://api.github.com/users/timholy/gists{/gist_id}","starred_url":"https://api.github.com/users/timholy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timholy/subscriptions","organizations_url":"https://api.github.com/users/timholy/orgs","repos_url":"https://api.github.com/users/timholy/repos","events_url":"https://api.github.com/users/timholy/events{/privacy}","received_events_url":"https://api.github.com/users/timholy/received_events","type":"User","site_admin":false},"created_at":"2015-10-01T19:27:39Z","updated_at":"2015-10-01T19:27:39Z","body":"Shoot, I missed that you were timing `f`, not `collect`.\r\n\r\nStill, for me, those are identical. Running `tk/backports5`\r\n```\r\njulia> versioninfo()\r\nJulia Version 0.4.0-rc3+30\r\nCommit 440c8c7* (2015-09-30 16:45 UTC)\r\nPlatform Info:\r\n  System: Linux (x86_64-linux-gnu)\r\n  CPU: Intel(R) Core(TM) i7 CPU       L 640  @ 2.13GHz\r\n  WORD_SIZE: 64\r\n  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Nehalem)\r\n  LAPACK: libopenblas\r\n  LIBM: libopenlibm\r\n  LLVM: libLLVM-3.3\r\n```\r\nPossibly fixed by https://github.com/JuliaLang/julia/pull/13355? (Which is included in `tk/backports5`, and the main reason I'm running it.)"}}