-
Notifications
You must be signed in to change notification settings - Fork 8
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
Speed up opportunities? #1
Comments
Ah, I see. Yes, I think a slightly better idiom for you to use in code like that might be something like this (with a few bonus optimizations): inverted_mask = BitVector(n) # or Vector{Bool} — benchmark to see which is faster
for …
nidx = rand(1:n) # you can just use rand here
to_invert = sort!(sample(1:n, nidx, replace=false)) # you can sort! in-place here
inverted_mask[:] = true
inverted_mask[to_invert] = false # you could even add @inbounds here
... = (y[to_invert, :], y[inverted_mask, :]) We could use a specialized internal type that simply wraps There seems to be a movement growing to make this easier, so I'll either register it or push for inclusion in the standard library in the next few weeks. |
Thanks for the tips! Since I'm working on my own array type, i've added the inversion pool to the type struct so that it doesn't need re-allocated for each lookup. Of course, this precludes parallel computation, but in my case, parallelism isn't really feasible. But, with inspiration from your interface, added NotRow/NotCol functions which work somewhat similarly. |
Thanks for writing this! The interface is super easy to use. Unfortunately, finding this package with google seems impossible. I was literally searching for things like "inverted vector index julia" and didn't see your package on the first couple of pages of results in any of those variations. :(
Therefore, I wrote my own function, that has a terrible interface. However, it seems to do fewer allocations, but this might be more because of the way it is used than anything else.
The function:
Usage of it (like I said, your interface is great)
Anyway, i'm benchmarking some critical code and wanted to migrate to your version, but i was getting like 20% fewer allocations with mine. Maybe there is something in mine you can use to optimize? In any case, 9/10 times I will be reaching for this. Hope it gets more popular / integrated in to the language some how!
Maybe if you comment with your code here, it will get more traction? JuliaLang/julia#1032
The text was updated successfully, but these errors were encountered: