Skip to content
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
merged 15 commits into from
Jan 13, 2017

Commits on Jan 5, 2017

  1. 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`.
    mbauman committed Jan 5, 2017
    Configuration menu
    Copy the full SHA
    8a55211 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5650778 View commit details
    Browse the repository at this point in the history
  3. More perf improvements

    * 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.
    mbauman committed Jan 5, 2017
    Configuration menu
    Copy the full SHA
    9b4bdef View commit details
    Browse the repository at this point in the history
  4. Type stable concatenation

    Because the abstract fallbacks now rely more upon dispatch, the effect of a type-instability in the indices is greater.
    mbauman committed Jan 5, 2017
    Configuration menu
    Copy the full SHA
    b85c1c7 View commit details
    Browse the repository at this point in the history
  5. 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.
    mbauman committed Jan 5, 2017
    Configuration menu
    Copy the full SHA
    82f9cde View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    3992c77 View commit details
    Browse the repository at this point in the history
  7. Revert "Type stable concatenation"

    This reverts commit f15ad88.
    mbauman committed Jan 5, 2017
    Configuration menu
    Copy the full SHA
    7753e66 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    a5d45bb View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    2b28d7a View commit details
    Browse the repository at this point in the history

Commits on Jan 6, 2017

  1. Configuration menu
    Copy the full SHA
    fc4563e View commit details
    Browse the repository at this point in the history
  2. Better deprecation messages

    mbauman committed Jan 6, 2017
    Configuration menu
    Copy the full SHA
    737a156 View commit details
    Browse the repository at this point in the history

Commits on Jan 7, 2017

  1. Configuration menu
    Copy the full SHA
    b0e90e1 View commit details
    Browse the repository at this point in the history
  2. Remove local variable N in cat

    redundant with typevar and throwing a warning.
    mbauman committed Jan 7, 2017
    Configuration menu
    Copy the full SHA
    9cd522c View commit details
    Browse the repository at this point in the history

Commits on Jan 12, 2017

  1. Configuration menu
    Copy the full SHA
    748fd0e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1b2b738 View commit details
    Browse the repository at this point in the history