Behaviour of enumerate in parallel 12712 Closed nilshg opened this Issue on Aug 20, 2015 ยท 3 comments Projects None yet Labels parallel Milestone No milestone Assignees No one assigned 5 participants nilshg elextr ivarne jakebolewski kshyatt Notifications nilshg nilshg commented on Aug 20, 2015 I first brought this up in the julia users group here: julia list a , b , c for i in enumerate list println i end 1, a 2, b 3, c But: julia addprocs 2 parallel for i in enumerate list println i end ERROR: `getindex` has no method matching getindex ::Enumerate Array ASCIIString,1 , ::UnitRange Int64 As Ismael-VC pointed out in the user group, it works in parallel with julia parallel for i in collect enumerate list println i end But it seems a bit confusing to me that the behaviour of enumerate changes depending on whether the loop is run in parallel or not. kshyatt kshyatt added the parallel label on Aug 20, 2015 ivarne ivarne referenced this issue on Aug 20, 2015 Closed add support for `enumerate` with starting index 12713 elextr elextr commented on Aug 21, 2015 I would assume that parallel needs to pass subsets of the enumeration to the separate processes, but iterators don't support any form of slicing or indexing so it is unable to and fails. The error message could be clearer though. Or if it can detect an iterator then parallel could do the collect itself. ivarne ivarne commented on Aug 21, 2015 Another solution would be to have a new function partition_paralell a::AbstractArray, n::Int , that return an array of roughly equal length iterables that can be serialized and distributed to workers. Relying on getindex and linear indexing with ranges has some disadvantages with non-array types. jakebolewski The Julia Language member jakebolewski commented on Aug 26, 2015 Duplicate of 10435. To make this more generic, we can implement a variety of leader follower iterators popularized by ZPL and more recently Chapel. This is basically what ivarne is describing. jakebolewski jakebolewski closed this on Aug 26, 2015 malmaud malmaud referenced this issue on Oct 14, 2015 Open parallel and zip 10435