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

Very slow subsetting for character #544

Closed
krlmlr opened this issue Nov 30, 2018 · 4 comments · Fixed by #551
Closed

Very slow subsetting for character #544

krlmlr opened this issue Nov 30, 2018 · 4 comments · Fixed by #551
Milestone

Comments

@krlmlr
Copy link
Member

krlmlr commented Nov 30, 2018

tidyverse/ggplot2#3018 (comment).

@krlmlr krlmlr added this to the 2.0.0 milestone Nov 30, 2018
@yutannihilation
Copy link
Member

yutannihilation commented Dec 4, 2018

Here's a quick profile of [.tbl_df on my laptop. It seems safe_match() in check_names_df.character() is the main cause of slow subsetting for character. So, I think you can fix this somehow.

But, as these checks seem basically necessary, I guess [.tbl_df will stay several times slower than [.data.frame for a while. Can I expect [.tbl_df will get as fast as [.data.frame in future? (or in version 2.0.0?)

Codes:

library(tibble)

d <- data.frame(a = 1, b = 2, c = 3)
t <- as_tibble(d)

profvis::profvis({for (i in 1:1e5) {t[, "c"]}})
profvis::profvis({for (i in 1:1e5) {t[, 3]}})

Results:
2018-12-04 12 16 28
2018-12-04 12 17 02

@krlmlr
Copy link
Member Author

krlmlr commented Dec 4, 2018

Thanks. That's the same profile I see. I think we might be able to make it ~8x faster if necessary, not sure if that's fast enough.

@yutannihilation
Copy link
Member

Yeah, the problem is we don't know how fast is fast enough... but ~8x faster sounds great.

krlmlr added a commit that referenced this issue Dec 19, 2018
- Faster subsetting with the `[` operator (#544).
@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2020

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants