You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
I didn't think get() copies, why is fun2() slowest here? #727
I'm almost sure it's because of this part in [.data.table:
if (is.null(irows)) {
for (sin seq_along(xcols)) { # xcols means non-join x columns, since join columns come from itarget=xcolsAns[s]
source=xcols[s]
ans[[target]] =x[[source]]
if (address(ans[[target]]) == address(x[[source]])) ans[[target]] = copy(ans[[target]])
}
} else {
for (sin seq_along(xcols)) {
target=xcolsAns[s]
source=xcols[s]
ans[[target]] = .Call(CsubsetVector,x[[source]],irows) # i.e. x[[source]][irows], but guaranteed new memory even for singleton logicals from R 3.1
}
}
get() fetches all columns and here is.null(irows) == TRUE and therefore runs the for-loop under the if-clause looping through each one of columns, copying each time, before assigning ans to .SD later on.
I think that solution proposed #4304 is a proper way to address this issue. It removes the burden of maintaining get optimisation. I think it is is reasonable to advise to use substitution rather than get, thus closing. SO should be updated when we will have it in master.
Activity
arunsrinivasan commentedon Jul 15, 2014
I'm almost sure it's because of this part in
[.data.table:get()fetches all columns and hereis.null(irows) == TRUEand therefore runs thefor-loopunder the if-clause looping through each one of columns, copying each time, before assigningansto.SDlater on.MichaelChirico commentedon Sep 2, 2019
I think that without
.SDcolsgethas to copy. So I'm not sure there's any fix to this besides supplying.SDcols... OK to close?jangorecki commentedon Mar 22, 2020
I think that solution proposed #4304 is a proper way to address this issue. It removes the burden of maintaining
getoptimisation. I think it is is reasonable to advise to use substitution rather thanget, thus closing. SO should be updated when we will have it in master.