Open grantmcdermott opened 2 years ago
From the internal side, this is not due to GForce, but due to not applying lapply optimization in the first place.
In your example this would be:
# lapply optimization changed j from 'lapply(.SD, sum)' to 'list(sum(dep_delay), sum(arr_delay), sum(air_time), sum(distance))'
It's possible to also do Map
and mapply
optimizations by expanding expressions to their list equivalences. If correctly expanded, GForce should smoothly take over from there.
In the easiest case of unary functions this should be just a small change.
Related to #5032 and #3815
I think if we had squeaky-clean internals on [
this would be pretty straightforward... at the moment I think it might be messy.
Leaving this as a "PRs accepted" request for now...
After recently extolling the virtues of
base::Map
overlapply
(quicker to type, direct equivalents in other languages, easy to add multiple arguments, etc.), I was a little surprised by the following:Created on 2022-02-16 by the reprex package (v2.0.1)
Re-running the
Map
version withverbose=TRUE
, the expected culprit appears:Is there a technical reason why
Map
shouldn't/wouldn't work with GForce, butlapply
does?Related (possibly even a duplicate): https://github.com/Rdatatable/data.table/issues/4225