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

WIP: switch to passing around a growable output object #154

Closed
wants to merge 18 commits into from
Closed

Conversation

hadley
Copy link
Member

@hadley hadley commented Jun 19, 2024

This approach looks pretty performant — about 1µs per element

f <- function(n) {
  output <- growable()
  for (i in 1:n) output$push(1:10)
  output$get()
}
bench::mark(
  f(10),
  f(100),
  f(1000),
  check = FALSE
)
#> # A tibble: 3 × 3
#>   expression      min   median
#>   <bch:expr> <bch:tm> <bch:tm>
#> 1 f(10)       11.69µs  14.72µs
#> 2 f(100)     111.85µs  120.7µs
#> 3 f(1000)      1.14ms   1.18ms

R/eval.R Outdated Show resolved Hide resolved
R/eval.R Outdated
@@ -202,7 +178,7 @@ evaluate_top_level_expression <- function(exprs,
handlers <- c(user_handlers, evaluate_handlers)

for (expr in exprs) {
srcindex <- length(output)
# srcindex <- length(output)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to restore this.

@hadley
Copy link
Member Author

hadley commented Jun 20, 2024

There's a minor change of behaviour here in that evaluate("stop('x'); 1") previously would have printed 1, but that's not actually what you see if you type that at the console.

hadley added a commit that referenced this pull request Jun 21, 2024
Need to wait for #154 so we can terminate the loop after these problematic errors.
@hadley
Copy link
Member Author

hadley commented Jun 21, 2024

Closing since it's now split up into multiple PRs and my to do list 😄

@hadley hadley closed this Jun 21, 2024
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.

1 participant