You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A for loop over a tuple of known length does not infer as "terminates" unless it is annotated with @assume_effects :terminates_locally. This seems like a reasonable thing for effect analysis to figure out.
julia> functionf(x...)
a = 0
for i in x
a += i
end
a
end
f (generic function with 1 method)
julia> Base.infer_effects(f, NTuple{2, Int})
(+c,+e,!n,!t,+s,+m,+u,+o,+r)
julia> Base.@assume_effects:terminates_locallyfunctiong(x...)
a = 0
for i in x
a += i
end
a
end
g (generic function with 1 method)
julia> Base.infer_effects(g, NTuple{2, Int})
(+c,+e,!n,+t,+s,+m,+u,+o,+r)
julia> @bf(1,2,3)
1.984 ns
julia> @bg(1,2,3)
1.134 ns
Iterating a Vector is also typically guaranteed to terminate locally. However it will be harder to determine when it is not (e.g. push! in the loop), and it may take many more iterations than with a tuple.
The text was updated successfully, but these errors were encountered:
A for loop over a tuple of known length does not infer as "terminates" unless it is annotated with
@assume_effects :terminates_locally
. This seems like a reasonable thing for effect analysis to figure out.Iterating a Vector is also typically guaranteed to terminate locally. However it will be harder to determine when it is not (e.g.
push!
in the loop), and it may take many more iterations than with a tuple.The text was updated successfully, but these errors were encountered: