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
searchsorted
It should be possible for searchsorted to search a view of an array without allocating.
julia> a = [0] 1-element Array{Int64,1}: 0 julia> @btime searchsorted($a, 0) 14.404 ns (0 allocations: 0 bytes) 1:1 julia> @btime searchsorted(view($a,1:1), 0) 37.277 ns (1 allocation: 48 bytes) 1:1 julia> @btime findfirst(x->x==0, view($a,1:1)) 5.833 ns (0 allocations: 0 bytes) 1 julia> versioninfo() Julia Version 1.5.0-DEV.645 Commit c3fc36707c (2020-04-18 20:13 UTC) Platform Info: OS: Linux (aarch64-unknown-linux-gnu) CPU: unknown WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-9.0.1 (ORCJIT, kryo)
The text was updated successfully, but these errors were encountered:
It's the view itself that allocates:
a = [0] @btime av = view($a, 1:1) # 11.396 ns (1 allocation: 48 bytes) @btime searchsorted($av, 0) # 10.577 ns (0 allocations: 0 bytes)
Thus a duplicate of #14955. Only in a few select cases the compiler is able to optimize the view away.
Sorry, something went wrong.
Ah, I see. Thanks.
No branches or pull requests
It should be possible for
searchsorted
to search a view of an array without allocating.The text was updated successfully, but these errors were encountered: