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
@ben-schwen somewhat related to your note, #4412 has some aspects of this but is more focused on logical expression evaluations. From the PR (note the 3 gForce optimized functions combined via |):
I believe I had done research and got your query to work using GForce using similar methods as the PR. I'd have to review my other branches more, but it's doable to optimize without changing the way the query looks. As your benchmark notes, it's much more memory intensive this route but is generally faster.
As an aside, should this issue be closed? I am not sure how to optimize {min_x = min(x); .(min_x, min_x/mean(x))} and there are other very similar issues about optimizing expressions to GForce optimizations.
?
As a simple user, sometimes we've been told in some R guidelines (maybe wrongly) to always put the package before, even for basic packages like utils
? As a simple user, sometimes we've been told in some R guidelines (maybe wrongly) to always put the package before, even for basic packages like utils
that will never be supported. authors might need to invoke the "real" head to get S3 dispatch for example. GForce head completely skips method dispatch of course
my snarky opinion is that the authors telling you to 'always qualify namespace' should stick to writing C++ if that's what they want so badly 🙃
Reacted by Toby Dylan Hocking, Jan Gorecki and AndyTwo2
? As a simple user, sometimes we've been told in some R guidelines (maybe wrongly) to always put the package before, even for basic packages like utils
@clerousset R 2.14.0 introduced namespaces as a feature, so conflicting names can be resolved from various namespaces, but it is a another feature of R that we can attach namespaces (library() / require() / NAMESPACE file) and do not have to prefix each function call with its namespace.
I can imagine there are some use cases to do it this, like when your dependencies chain (and/or their dependencies chain, and/or their dependencies chain, and/or ...) is so wildly out of control that you cannot be sure if in future functions like head won't be added to any of its dependencies (and/or any of its dependencies, and/or any of its dependencies, and/or ...).
But if that is your problem then it comes bundled with many others problems (and for robust and production grade costs definitely make sense to rethink your strategy), and then much better way to solve this particular one is to explicitly state imported functions in NAMESPACE file.
Activity
ben-schwen commentedon Apr 15, 2023
I think another case of this also appears in the db-benchmark (now resurrected by duckdblabs at https://github.com/duckdblabs/db-benchmark) as Q2 advanced group by
Since
DT[, .(range_v1_v2=max(v1, na.rm=TRUE)-min(v2, na.rm=TRUE)), by=id3]could be rewritten using chaining.@jangorecki is query rewriting something viable in the benchmarks or does this lead it in the wrong direction?
With current master this gives a good speedup
jangorecki commentedon Apr 15, 2023
I would keep it as it is, benchmark also compares query syntax
ColeMiller1 commentedon Apr 16, 2023
@ben-schwen somewhat related to your note, #4412 has some aspects of this but is more focused on logical expression evaluations. From the PR (note the 3 gForce optimized functions combined via
|):I believe I had done research and got your query to work using GForce using similar methods as the PR. I'd have to review my other branches more, but it's doable to optimize without changing the way the query looks. As your benchmark notes, it's much more memory intensive this route but is generally faster.
As an aside, should this issue be closed? I am not sure how to optimize
{min_x = min(x); .(min_x, min_x/mean(x))}and there are other very similar issues about optimizing expressions to GForce optimizations.clerousset commentedon Jan 25, 2024
Can I add to this topic that :
?
As a simple user, sometimes we've been told in some R guidelines (maybe wrongly) to always put the package before, even for basic packages like
utils(behaviour checked for data.table 6f43a96)
MichaelChirico commentedon Jan 25, 2024
that will never be supported. authors might need to invoke the "real" head to get S3 dispatch for example. GForce head completely skips method dispatch of course
my snarky opinion is that the authors telling you to 'always qualify namespace' should stick to writing C++ if that's what they want so badly 🙃
jangorecki commentedon Jun 26, 2025
@clerousset R 2.14.0 introduced namespaces as a feature, so conflicting names can be resolved from various namespaces, but it is a another feature of R that we can attach namespaces (
library()/require()/NAMESPACEfile) and do not have to prefix each function call with its namespace.I can imagine there are some use cases to do it this, like when your dependencies chain (and/or their dependencies chain, and/or their dependencies chain, and/or ...) is so wildly out of control that you cannot be sure if in future functions like
headwon't be added to any of its dependencies (and/or any of its dependencies, and/or any of its dependencies, and/or ...).But if that is your problem then it comes bundled with many others problems (and for robust and production grade costs definitely make sense to rethink your strategy), and then much better way to solve this particular one is to explicitly state imported functions in
NAMESPACEfile.