# "Functional State" Iterators & Why isn't this loop as fast as entitlement?

**URL:** <https://discourse.julialang.org/t/functional-state-iterators-why-isnt-this-loop-as-fast-as-entitlement/22282>\
**Category:** Performance\
**Tags:** development\
**Created:** [March 24, 2019, 6:24pm UTC](https://discourse.julialang.org/t/functional-state-iterators-why-isnt-this-loop-as-fast-as-entitlement/22282 "2019-03-24T18:24:24Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![c42f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c42f/32/52842_2.png) [@c42f](https://discourse.julialang.org/u/c42f)\
**Post date:** [March 25, 2019, 6:02am UTC](https://discourse.julialang.org/t/functional-state-iterators-why-isnt-this-loop-as-fast-as-entitlement/22282/4 "2019-03-25T06:02:58Z")

</div>

I didn’t read all the code here, but the general issue of how to express efficient iteration kernels in an iterator interface brings to mind the transducer approach as a promising alternative. In particular I thought the following comment about `foldl` implementations was particularly interesting:

> [@ANN: Transducers.jl, efficient and composable algorithms for map- and reduce-like operations](https://discourse.julialang.org/t/ann-transducers-jl-efficient-and-composable-algorithms-for-map-and-reduce-like-operations/19159/19):
>
> Another thought: I think the best “feature” of transducers for performance-oriented language like Julia is actually not transducers themselves but rather the foldl implementations specialized for container types. I guess that’s not news since Julia Base has very efficient foldl/mapfoldl. However, foldl (or mapfoldl) itself is not really composable — that’s where transducers come in. Transducers are composable “pre-processors” of the “reducing function” op you passed to foldl. I think one of…

See also the documentation section in Transducers.jl regarding the structure of the lowered loops:  
[https://tkf.github.io/Transducers.jl/dev/#Difference-to-iterators-1](https://tkf.github.io/Transducers.jl/dev/#Difference-to-iterators-1)

---

_[View the full topic](https://discourse.julialang.org/t/functional-state-iterators-why-isnt-this-loop-as-fast-as-entitlement/22282)._
