I see. Just removed the lazyness and got ~800ms. (defn generate-tree [[h & t :as coll]] (if (seq coll) (let [lr (generate-tree t)] [h lr lr]) nil))
(defn to-list [[v l r :as node]] (if-not (nil? node) (into (to-list l) (conj (to-list r) v)) [])) On Monday, July 23, 2012 11:20:50 PM UTC+3, tbc++ wrote: > > > Thanks. But I don't do any number crunching here - just a huge structure > > creation in memory. I can't get why removing the 'lazy-seq' wrapper from > the > > second 'concat' argument make things 10x times slower. > > Lazy-seqs require the allocation of a LazySeq object. Due to the lazy > nature of this structure, we have to protect against multiple > evaluation. This means that certain methods have to be synchronized: > ( > https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LazySeq.java). > > > All that makes it quite a bit slower than a simple Iterator. > > > Timothy > -- 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