{"action":"opened","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/12256","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/12256/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/12256/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/12256/events","html_url":"https://github.com/JuliaLang/julia/issues/12256","id":96412269,"number":12256,"title":"precompiling cfunction calls","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":0,"created_at":"2015-07-21T20:44:34Z","updated_at":"2015-07-21T20:44:34Z","closed_at":null,"body":"I noticed in stevengj/PyCall.jl#167 that, even after running `Base.compile`, some `cfunction` calls in my `__init__` function were taking a significant amount of time (0.8 seconds for 6 functions).\r\n\r\nI could work around this by adding some explicit `precompile` lines in order to ensure that these were compiled, but this raises three problems:\r\n\r\n* Calls to `cfunction` in `__init__` should really cause the corresponding functions to be precompiled automatically.\r\n\r\n* Even after precompiling, `cfunction` was quite expensive: 0.25 seconds for 6 functions.\r\n\r\n* Calling `precompile` causes the functions to be compiled at the wrong time — *before* `__init__` is called rather than *after*.  Since my `__init__` initializes some `global const` variables that are referenced in the precompiled functions, this means that type inference does not work properly when precompiling (since Julia does not know the types of those globals yet).\r\n\r\ncc: @vtjnash "}}