-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recent update to 2.1.3 breaks overloading of [[ #96
Comments
Hm, what are you using |
The fix for this particular issue is simple, but I'm wondering if there's a principled reason for R6 to avoid using |
I have an object where I am simulating list like access (not so much a Another one where I implemented vector-like access, and wanted to have [[ For now I disabled [[, but I wanted to alert you to the issue. For R6 It is being used here https://github.com/Novartis/hdf5r/blob/master/R/R6Classes_H5R.R On Fri, Sep 30, 2016 at 6:21 PM, Winston Chang notifications@github.com
|
I think it should be possible to replace every internal instance of library(microbenchmark)
e <- new.env()
e$x <- 1
# Test speeds of $ and .subset2, for present and missing items
microbenchmark(times = 1000,
e$x,
.subset2(e, "x"),
e$y,
.subset2(e, "y")
)
# Unit: nanoseconds
# expr min lq mean median uq max neval
# e$x 208 232 282.453 257 306.0 3754 1000
# .subset2(e, "x") 178 192 229.999 217 241.0 661 1000
# e$y 183 212 253.080 226 278.5 780 1000
# .subset2(e, "y") 149 176 206.165 185 205.5 5587 1000 |
Cool, thanks. |
In general the internal implementations of the methods for class In proper modern OO-ish languages like CLU from 1975, the methods get an
But we probably need to leave this for R7. :) Sorry, it is just Friday afternoon.... gist is, yeah, avoiding |
I just pushed a fix. You can replace For future reference (R 3.3.1 on Linux): library(microbenchmark)
e <- new.env()
i <- 1
# Test speeds of $<- and assign(). Also increment i each time so that new values
# are assigned
microbenchmark(times = 1000,
e$x <- (i <<- i + 1),
assign("x", (i <<- i + 1), envir = e),
(i <<- i + 1) # Find how much time is spent in incrementing i
)
# Unit: nanoseconds
# expr min lq mean median uq max neval
# e$x <- (i <<- i + 1) 902 992.0 1253.113 1072.5 1221.5 36127 1000
# assign("x", (i <<- i + 1), envir = e) 1148 1270.5 1523.144 1339.0 1514.0 16897 1000
# (i <<- i + 1) 321 344.0 419.003 353.0 383.0 11116 1000 |
Hi,
I am using R6 methods and for some of them I am overloading the [[ operator to do something specific. The recent changes to the clone method with
breaks this functionality as the public_bind_env[[name]] assume normal operation of "[[" for the class.
The text was updated successfully, but these errors were encountered: