people who love doing stream processing would attack an extra allocation. On Fri, Jan 23, 2009 at 12:09 PM, Konrad Hinsen <konrad.hin...@laposte.net>wrote:
> > On Jan 23, 2009, at 14:04, Rich Hickey wrote: > > >> Then why not make a pipeline using lazy sequences right from the > >> start? I don't see anything that I could do better with streams than > >> with lazy sequences. > >> > > > > There are a couple of advantages. First, streams are faster, at least > > 2x faster. Since a lazy sequence must allocate per stage, a multi- > > stage pipeline would incur multiple allocations per step. A stream > > could be built that has no allocation other than the results. If your > > calculations per step are significant, they'll dominate the time. but > > when they are not, this allocation time matters. > > > > Second, streams are fully lazy. Seqs could be made fully lazy, but > > currently are not. > > > > Third, stream iters currently provide transparent MT access. Doing the > > same for a seq means wrapping it in a ref. > > Thanks for those explanations, that makes a lot of sense. > > I just wonder about the performance aspect. If I have a pipeline > stage with very little computational cost, say adding 1 to every > element, the I would expect the overhead of the iter layer and the > thread-safeness to dominate CPU time anyway. Does an allocation > really add that much on top of that that it makes a difference? > > Konrad. > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---