-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simpler and more systematic index conversions
This patch dramatically simplifies the fallback indexing algorithms for arrays by standardizing the way in which the passed indices are converted `to_index` and by rigorously defining what a supported index type is. The very first thing that occurs within the fallback indexing methods is that the passed indices are converted to a supported indexing type by `to_indices(...)`. A supported index type is either `Int` or an `AbstractArray` of indices. This means that it is at this point that both `Colon` and arrays of booleans get converted to collections of indices (as specialized array types: `Slice` and `LogicalIndex`, respectively). This *drastically* simplifies much of the internal logic. Whereas we had previously encoded the special behaviors of `:` indexing in about four places, this patch does it once and then stores the result in a `Slice` AbstractVector. Similarly, `CartesianIndex` is now converted within `to_indices`, as well. In addition to simplifying the internal definitions, this patch also makes it easier for both external packages and Base to add new behaviors in a systematic fashion. Simple extensions would include things like `Not` indices and [EndpointRanges.jl](https://github.com/JuliaArrays/EndpointRanges.jl). Additionally, logical indexing is now represented by a specialized `LogicalIndex` type that enables fast iteration over the boolean mask without allocations. This allows index conversions to occur before checking bounds, and should enable further optimizations for LinearSlow arrays. ### Breaking Behaviors: * The stored type of indices in SubArrays change from `Colon` to `Slice`.
- Loading branch information
Showing
12 changed files
with
362 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.