# Improving pullback speed with list comprehension

**URL:** <https://discourse.julialang.org/t/improving-pullback-speed-with-list-comprehension/90361>\
**Category:** Performance\
**Tags:** zygote\
**Created:** [November 16, 2022, 4:29pm UTC](https://discourse.julialang.org/t/improving-pullback-speed-with-list-comprehension/90361 "2022-11-16T16:29:14Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [November 16, 2022, 5:17pm UTC](https://discourse.julialang.org/t/improving-pullback-speed-with-list-comprehension/90361/3 "2022-11-16T17:17:08Z")

</div>

Maybe I was unclear in that thread. The problem is control flow inside the _body_ of the array comprehension and not with the comprehension itself. Notice how in [Suggestions to improve Zygote performance for simple vector map/broadcast/comprehension? - #5 by ToucheSir](https://discourse.julialang.org/t/suggestions-to-improve-zygote-performance-for-simple-vector-map-broadcast-comprehension/35207/5) I replace the ternary inside the `[... for ...]` with an `ifelse` _still inside_ the `[... for ...]`.

So you wouldn’t need a custom rule for `compute_many_prods`, but one for `(f,g) -> f * g * i`. Of course this particular example won’t be any faster because the `f * g * i` doesn’t use any control flow, so you’ll want a better MWE that does.

---

_[View the full topic](https://discourse.julialang.org/t/improving-pullback-speed-with-list-comprehension/90361)._
