futureverse / futureverse/globals

IDEA: Improve performance by early skipping in findGlobals()

Open
#39 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
R
Stars
29
Forks
3
PR merge metrics
No merged PRs in 30d

Description

I've [just made](https://github.com/HenrikBengtsson/globals/commit/566e3e9395ab5050387396c894b06fb099f96a66) `globals::findGlobals(X)` significantly faster when `X` is long and contain lots of elements with basic data types. The gist of this improvement is to skip elements "early" that cannot contain globals:
```r
types <- unlist(lapply(expr, FUN = storage.mode), use.names = FALSE)
keep <- which(!(types %in% c("logical", "integer", "double", "complex", "character", "raw", "NULL")))
globals <- lapply(expr[keep], FUN = findGlobals, ...)
```

# Idea
Can this approach be done efficiently also in a nested approach, e.g. when `X` is a list of lists? Can it be done efficiently using plain R code, or do we need to implement this is native code? If we go for native code, other parts of the package could also go native - there's a lot of "walking" around in structures going on.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.