Skip to content
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

light setDT #4477

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

light setDT #4477

wants to merge 1 commit into from

Conversation

jangorecki
Copy link
Member

@jangorecki jangorecki commented May 22, 2020

Provides more lightweight interface for setDT. Use cases are rather uncommon, of using setDT in big loops, which is described in #4476.
It may be useful for our internal usage of setDT where its input is already produced by our code and not provided by user.
There was also request for interface to alloccol on C level, the C function here is well addressing that, #4439.

library(data.table)
df1 = data.frame(x=1:4, y=1:2)
df2 = copy(df1)
microbenchmark::microbenchmark(times=1000,
  normal = setDT(df1)[, sum(x), y],
  simple = setDT(df2, asis=TRUE, return=TRUE)[, sum(x), y]
)
#Unit: microseconds
#   expr     min       lq     mean   median       uq      max neval
# normal 654.000 676.3505 730.4088 707.9065 725.1735 9311.567  1000
# simple 571.862 594.5105 652.3667 626.2590 642.4785 8279.154  1000

microbenchmark::microbenchmark(times=1,
  normal = for (i in 1:1e3) setDT(df1),
  simple = for (i in 1:1e3) setDT(df2, asis=TRUE, return=TRUE)
)
#Unit: milliseconds
#   expr       min        lq      mean    median        uq       max neval
# normal 77.017866 77.017866 77.017866 77.017866 77.017866 77.017866     1
# simple  8.291629  8.291629  8.291629  8.291629  8.291629  8.291629     1

No tests yet. Setting WIP for now.
Will add tests and C exports for #4439 after initial round of feedback.

@jangorecki jangorecki added the WIP label May 22, 2020
@jangorecki jangorecki linked an issue May 22, 2020 that may be closed by this pull request
@MichaelChirico MichaelChirico marked this pull request as draft February 19, 2024 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setDT could be much simpler
2 participants