Skip to content

Optimize away getitem in more cases #2146

Closed

Description

@jakirkham

In some cases slicing could be treated as a no-op, but does not appear to be currently. This issue exists to enumerate a few known cases and try to find a way to optimize away all such cases. Also these can be interleaved with more of the same (e.g. d[:, :] or d[:, 0:]) to get other cases too.

Currently works:

  • d[:]
  • d[::]

Not optimized:

  • d[...]
  • d[0:]
  • d[::1]
  • d[0::1]
  • d[0:s] where s = d.shape[0] or s is larger.
  • d[0:s:1] where s = d.shape[0] or s is larger.

Activity

  1. jakirkham commented on Apr 14, 2017

    @jakirkham
    MemberAuthor

    FWIW I have a small, dependency free, permissively licensed, pure Python, slice normalization library, which would convert all of the above slices into 0:s:1, which would make it easier to handle all of these. Just something to think about.

  2. jakirkham commented on Dec 8, 2017

    @jakirkham
    MemberAuthor

    Not sure when, but this has been resolved. Adding some tests in PR ( #2978 ) to make sure that these remain true in the future.

    Edit: Looks like PR ( #2601 ) fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions