Re: [Rd] JIT compiler does not compile closures with custom environments

2021-08-18 Thread Taras Zakharko
That’s the interim solution I am using right now (manually precompiling most functions), but I generate quite a lot of closures dynamically in my code and the potential performance loss is a bit worrying… I don’t think the current behavior is expected based on what the documentation says. Cheer

Re: [Rd] JIT compiler does not compile closures with custom environments

2021-08-18 Thread Duncan Murdoch
Forgot to add: you could define f_env like this to get it compiled: f_env <- local({ cmpfun(function(x) { for(i in 1:1) x <- x + 1 x }) }) Not as convenient as JIT, but it gets the job done... Duncan Murdoch On 18/08/2021 10:33 a.m., Duncan Murdoch wrote: On 18/08/2021 9:00 a

Re: [Rd] JIT compiler does not compile closures with custom environments

2021-08-18 Thread Duncan Murdoch
On 18/08/2021 9:00 a.m., Taras Zakharko wrote: I have encountered a behavior of R’s JIT compiler that I can’t quite figure out. Consider the following code: f_global <- function(x) { for(i in 1:1) x <- x + 1 x } f_env <- local({ function(x) { for(i in 1