-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: Speedier, simpler and more systematic index conversions #19730
Merged
Commits on Jan 5, 2017
-
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`.
Configuration menu - View commit details
-
Copy full SHA for 8a55211 - Browse repository at this point
Copy the full SHA 8a55211View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5650778 - Browse repository at this point
Copy the full SHA 5650778View commit details -
* Move non-inlined function boundary up one method in the nonscalar indexing call chain and simplify the setindex call chain. * Avoid calling indices(A) when it is known to be not needed. It'd be nice if Julia could identify this, but this is a very simple workaround.
Configuration menu - View commit details
-
Copy full SHA for 9b4bdef - Browse repository at this point
Copy the full SHA 9b4bdefView commit details -
Because the abstract fallbacks now rely more upon dispatch, the effect of a type-instability in the indices is greater.
Configuration menu - View commit details
-
Copy full SHA for b85c1c7 - Browse repository at this point
Copy the full SHA b85c1c7View commit details -
Specialize indexing into ::Array with mixtures of Integers and Cartes…
…ianIndices. This is a little unfortunate that we no longer try to call the canonical method multiple times when indexing with CartesianIndex, but I think the standardization is worth it.
Configuration menu - View commit details
-
Copy full SHA for 82f9cde - Browse repository at this point
Copy the full SHA 82f9cdeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3992c77 - Browse repository at this point
Copy the full SHA 3992c77View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7753e66 - Browse repository at this point
Copy the full SHA 7753e66View commit details -
Configuration menu - View commit details
-
Copy full SHA for a5d45bb - Browse repository at this point
Copy the full SHA a5d45bbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2b28d7a - Browse repository at this point
Copy the full SHA 2b28d7aView commit details
Commits on Jan 6, 2017
-
Configuration menu - View commit details
-
Copy full SHA for fc4563e - Browse repository at this point
Copy the full SHA fc4563eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 737a156 - Browse repository at this point
Copy the full SHA 737a156View commit details
Commits on Jan 7, 2017
-
Configuration menu - View commit details
-
Copy full SHA for b0e90e1 - Browse repository at this point
Copy the full SHA b0e90e1View commit details -
Remove local variable N in cat
redundant with typevar and throwing a warning.
Configuration menu - View commit details
-
Copy full SHA for 9cd522c - Browse repository at this point
Copy the full SHA 9cd522cView commit details
Commits on Jan 12, 2017
-
Configuration menu - View commit details
-
Copy full SHA for 748fd0e - Browse repository at this point
Copy the full SHA 748fd0eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1b2b738 - Browse repository at this point
Copy the full SHA 1b2b738View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.