-
-
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
Simplify A[1, end] lowering with lastindex(A, n) #25763
Conversation
This implements a new method of `lastindex` to specify a given dimension, and then uses that new method in the lowering of `end` within multi-dimensional indices. Previously, this would have lowered directly to `last(axes(A, d))` for `end` in position `d`. Given that `axes` (and multidimensional indexing generally) are array-centric concepts, I have only implemented this for `::AbstractArray`, with a deprecation for all other types suggesting implemention if sensible. I have similarly defined `firstindex(A, d)` - it will be available for its syntax transformation in the future.
src/julia-syntax.scm
Outdated
@@ -90,16 +90,16 @@ | |||
;; the array `a` in the `n`th index. | |||
;; `tuples` are a list of the splatted arguments that precede index `n` | |||
;; `last` = is this last index? | |||
;; returns a call to lastindex(a) or last(axes(a,n)) | |||
;; returns a call to lastindex(a) or lastindex(a,n)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
superfluous close paren
This attempts to address some of the performance regressions observed with the Stateful iterator #25763. It gets most of the way there, but unfortunately still ends up allocating the `Stateful` iterator object rather than propagating through the fields. Getting the rest of the way there will require some compiler tweaks.
I missed this change in #25763.
I missed this change in #25763.
It would be nice to document the new methods. Also |
Just a heads up this is missing a deprecation for the rename of |
This does implement a deprecation. Are you referring to a deprecation of |
I see, that makes sense as to why I was not getting the deprecation. Thank you. |
This implements a new method of
lastindex
to specify a given dimension, and then uses that new method in the lowering ofend
within multi-dimensional indices. Previously, this would have lowered directly tolast(axes(A, d))
forend
in positiond
. Given thataxes
(and multidimensional indexing generally) are array-centric concepts, I have only implemented this for::AbstractArray
, with a deprecation for all other types suggesting implemention if sensible. I have similarly definedfirstindex(A, d)
(albeit without the deprecation). It will be available for its syntax transformation in the future.