Re: [julia-dev] ndenumerate?

126 views
Skip to first unread message

Tim Holy

unread,
Jun 5, 2013, 5:33:32 PM6/5/13
to juli...@googlegroups.com
Welcome!

It's a nice iterator. n-dimensional (cartesian) iteration has been mulled over
for some time, with no permanent consensus emerging.

In the meantime, you may also be interested in the Cartesian package. In my
tests Cartesian is a bit faster than yours, but perhaps that will spur you on!

https://github.com/timholy/Cartesian.jl

Best,
--Tim


On Wednesday, June 05, 2013 01:19:19 PM James Porter wrote:
> All—
>
> I'm a student at Hacker School this summer; I wrote a little iterator
> type<https://github.com/porterjamesj/learn-julia/blob/master/ndenumerate.jl
> >for n-dimensional enumeration of arrays, like in
> numpy<http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndenumerate
> .html>. Its conceptually not much different than using enumerate() and then
> calling ind2sub() on the index, but is a nice syntactic sugar to have
> (imho) and in my tests it is about 2x faster than enumerate (I think since
> it is restricted to arrays as opposed to all iterables). Is there interest
> in adding this to the language? If so, where should it go?
> base/iterators.jl? base/array/jl?
>
> Best
> James Porter

James Porter

unread,
Jun 5, 2013, 8:08:29 PM6/5/13
to juli...@googlegroups.com
oh excellent

I will use that, thanks

On Wednesday, June 5, 2013 4:19:19 PM UTC-4, James Porter wrote:
All—

I'm a student at Hacker School this summer; I wrote a little iterator type for n-dimensional enumeration of arrays, like in numpy. Its conceptually not much different than using enumerate() and then calling ind2sub() on the index, but is a nice  syntactic sugar to have (imho) and in my tests it is about 2x faster than enumerate (I think since it is restricted to arrays as opposed to all iterables). Is there interest in adding this to the language? If so, where should it go? base/iterators.jl? base/array/jl?

Best
James Porter

James Porter

unread,
Jun 5, 2013, 8:10:37 PM6/5/13
to juli...@googlegroups.com
Also, for whatever its worth, I'd argue for having cartesian iteration in the language; I like having it in numpy a lot.
Reply all
Reply to author
Forward
0 new messages