I am using Clojure data structures all over the place but I am not using any lazy evaluation. Is there a performance penalty for using lazy structures everywhere?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From the source code:
clojure.lang.Cons(strict list element,clojure.lang.PersistentListis very similar), https://github.com/clojure/clojure/blob/1.2.0/src/jvm/clojure/lang/Cons.java#L34clojure.lang.LazySeq(lazy sequence element), https://github.com/clojure/clojure/blob/1.2.0/src/jvm/clojure/lang/LazySeq.java#L77where
So you’re definitely paying a price. It depends very much on each particular use case how much that price affects you and whether it’s offset by the memory savings and lack of wasted computation that lazy evaluation buys you.