There are many ways on how you can improve the performance of loop/recur, and most of them depends on the type of a thing you are iterating through. With reducers (and transducers), the iteration part is decoupled from the reduction part, so they offer a mechanism that chooses the optimal iteration strategy for the collection that is passed in.
On Fri, Apr 29, 2016 at 12:46 PM, Camilo Roca <car...@gmail.com> wrote: > > I have been hearing a lot of Clojure's use of an internalReduce protocol, > which seems to speed up things when using reduce. > Now the thing is that a lot of people also claim that tail-call-recursion > is also pretty fast, which lets me wondering: > > - if I could replace a loop/recur with an equivalent reduce/reduced > approach, do I see performance gains? > > Obviously the immediate answer is just "benchmark it", but so far I > haven't found an stable solution to this question. The benchmark seems to > go sometimes for loop/recur and some others for reduce/reduced. I also know > that when doing primitive math, loop/recur performs better than > reduce/reduced, but I was wondering in which cases (regardless of idiomatic > or nor) would a reduce approach be preferred over a loop/recur? > > Any thoughts on this? > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.