{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/16691","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/16691/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/16691/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/16691/events","html_url":"https://github.com/JuliaLang/julia/pull/16691","id":157809327,"number":16691,"title":"RFC: Function argument to `mean`, akin to `sum`","user":{"login":"ararslan","id":6396159,"avatar_url":"https://avatars.githubusercontent.com/u/6396159?v=3","gravatar_id":"","url":"https://api.github.com/users/ararslan","html_url":"https://github.com/ararslan","followers_url":"https://api.github.com/users/ararslan/followers","following_url":"https://api.github.com/users/ararslan/following{/other_user}","gists_url":"https://api.github.com/users/ararslan/gists{/gist_id}","starred_url":"https://api.github.com/users/ararslan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ararslan/subscriptions","organizations_url":"https://api.github.com/users/ararslan/orgs","repos_url":"https://api.github.com/users/ararslan/repos","events_url":"https://api.github.com/users/ararslan/events{/privacy}","received_events_url":"https://api.github.com/users/ararslan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/maths","name":"maths","color":"009800"},{"url":"https://api.github.com/repos/JuliaLang/julia/labels/performance","name":"performance","color":"d7e102"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2016-06-01T02:15:18Z","updated_at":"2016-06-08T05:20:09Z","closed_at":"2016-06-08T05:17:12Z","pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/16691","html_url":"https://github.com/JuliaLang/julia/pull/16691","diff_url":"https://github.com/JuliaLang/julia/pull/16691.diff","patch_url":"https://github.com/JuliaLang/julia/pull/16691.patch"},"body":"The functions `sum` and `prod` both accept a `Callable` argument that's mapped over the input before being reduced. This PR adds that functionality to `mean` as well.\r\n\r\nIt's faster and uses less memory than calling `map` then `mean`. Here are some timing results on my computer:\r\n```julia\r\njulia> @time mean_pr(isodd, 1:100_000_000)\r\n  0.185983 seconds (1.59 M allocations: 30.847 MB, 5.89% gc time)\r\n0.5\r\n\r\njulia> @time mean_pr(isodd, 1:100_000_000)\r\n  0.132717 seconds (1.57 M allocations: 30.000 MB, 2.48% gc time)\r\n0.5\r\n\r\njulia> @time mean_pr(isodd, 1:100_000_000)\r\n  0.142011 seconds (1.57 M allocations: 30.000 MB, 2.58% gc time)\r\n0.5\r\n\r\njulia> @time Base.mean(map(isodd, 1:100_000_000))\r\n  0.422005 seconds (13.29 k allocations: 95.957 MB, 0.39% gc time)\r\n0.5\r\n\r\njulia> @time Base.mean(map(isodd, 1:100_000_000))\r\n  0.408025 seconds (12 allocations: 95.368 MB, 2.34% gc time)\r\n0.5\r\n\r\njulia> @time Base.mean(map(isodd, 1:100_000_000))\r\n  0.373496 seconds (12 allocations: 95.368 MB, 2.46% gc time)\r\n0.5\r\n```"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/224490404","html_url":"https://github.com/JuliaLang/julia/pull/16691#issuecomment-224490404","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/16691","id":224490404,"user":{"login":"ararslan","id":6396159,"avatar_url":"https://avatars.githubusercontent.com/u/6396159?v=3","gravatar_id":"","url":"https://api.github.com/users/ararslan","html_url":"https://github.com/ararslan","followers_url":"https://api.github.com/users/ararslan/followers","following_url":"https://api.github.com/users/ararslan/following{/other_user}","gists_url":"https://api.github.com/users/ararslan/gists{/gist_id}","starred_url":"https://api.github.com/users/ararslan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ararslan/subscriptions","organizations_url":"https://api.github.com/users/ararslan/orgs","repos_url":"https://api.github.com/users/ararslan/repos","events_url":"https://api.github.com/users/ararslan/events{/privacy}","received_events_url":"https://api.github.com/users/ararslan/received_events","type":"User","site_admin":false},"created_at":"2016-06-08T05:20:08Z","updated_at":"2016-06-08T05:20:08Z","body":"My pleasure. Thanks again for your help, everyone! This was a good learning experience."}}
{"actor":{"display_login":"ararslan"}}