Faster searchsorted methods for range and array inputs#38527
Faster searchsorted methods for range and array inputs#38527IanButterworth wants to merge 2 commits intoJuliaLang:masterfrom
Conversation
8325e0e to
a1e4c1f
Compare
|
Is it necessary to require one-based indexing at all? Perhaps |
|
Maybe! Would zero become I didn't feel confident enough to try to handle non one based indexed ranges. I assume that it would require adding test cases for stuff out in the ecosystem that I'm unaware of |
|
The only example I know if is the axes of OffsetArrays, which behave like this: julia> OffsetArray('a':'z', -10)
'a':1:'z' with indices -9:16
julia> axes(ans, 1)
OffsetArrays.IdOffsetRange(-9:16)
julia> axes(ans, 1)
OffsetArrays.IdOffsetRange(-9:16)The general idea here is similar to JuliaMath/IntervalSets.jl#63, in which it wasn't so hard to allow offsets. But that can depend on the package for tests. I think there is a (simplified?) implementation of this loaded for tests, e.g. https://github.com/JuliaLang/julia/blob/master/test/offsetarray.jl |
|
Is the addition of the new API (the bang versions of |
|
Not necessary, but logical I think. I think it would be odd to add the array-based methods without allowing preallocation. Do you think the PR needs to be split? |
Refs performance issue noted in #38527
a1e4c1f to
ccc981c
Compare
|
Nice. Thanks! |
Refs performance issue noted in #38527
…Lang#40358) Refs performance issue noted in JuliaLang#38527
…Lang#40358) Refs performance issue noted in JuliaLang#38527
…Lang#40358) Refs performance issue noted in JuliaLang#38527
For searching through an AbstractRange, the fastest one can use
searchsortedfirstto evaluate multiple values currently is:This PR provides the following, which only checks for one-based indexing and the length of
ronce, given they are expensive. It can also be preallocated:I didn't extend the methods for searching through AbstractVectors, as I didn't see a performance limitation with using those looped through values