We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
as_mapper.default()
Nearly half the time in this example is spend in as_mapper.default(). The issue i
x <- as.list(1:20) x[21] <- list(NULL) for (i in 1:10e3) { purrr::detect_index(x, is.null) }
This leads to the curious situation that it is faster to manually wrap is.null() yourself in a function:
is.null()
x <- as.list(1:20) x[21] <- list(NULL) bench::mark( wrapped = purrr::detect_index(x, function(x) is.null(x)), prim = purrr::detect_index(x, is.null) ) #> # A tibble: 2 × 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl> #> 1 wrapped 61µs 66.1µs 13236. 446KB 16.6 #> 2 prim 129µs 145.4µs 6387. 232KB 14.6
Created on 2023-07-05 with reprex v2.0.2
The text was updated successfully, but these errors were encountered:
Hard to see how to fix without breaking this test:
test_that("primitive functions are wrapped", { expect_identical(as_mapper(`-`)(.y = 10, .x = 5), -5) expect_identical(as_mapper(`c`)(1, 3, 5), c(1, 3, 5)) })
But maybe that's ok since we don't generally expect - to respect named arguments?
-
Sorry, something went wrong.
No branches or pull requests
Nearly half the time in this example is spend in
as_mapper.default()
. The issue iThis leads to the curious situation that it is faster to manually wrap
is.null()
yourself in a function:Created on 2023-07-05 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: