Thanks for the explanation, Luke! I’ll keep this behavior in mind.
> On 18 Aug 2021, at 16:45, luke-tier...@uiowa.edu wrote:
>
> On Wed, 18 Aug 2021, Duncan Murdoch wrote:
>
>> 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 qui
On 18/08/2021 10:45 a.m., luke-tier...@uiowa.edu wrote:
On Wed, 18 Aug 2021, Duncan Murdoch wrote:
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) {
On Wed, 18 Aug 2021, Duncan Murdoch wrote:
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 <-
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
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
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
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:1) x <- x + 1
x
}
})
compiler::ena