Hi, On 5 Apr., 14:25, Ken Wesson <kwess...@gmail.com> wrote:
> I don't think so. I just tested it and adding a call to seq there > causes it to retain more data in memory, longer, not the other way > around. I don't understand this from a logical point of view. (seq (drop- while ...)) can only *remove* references, not *add* them. In my understanding placing seq there places you at the cross roads. With seq, you get (ideal) core partition-by: eager groups, no references to head group in the rest. Without seq, you get: lazy groups, references to head group in the rest. In the latter case the references only go away with realisation of the rest. I lean out of the window and claim: you can't have both—lazy groups and no references to head group items in the rest. Using your benchmark approach again: user=> (do ...) ; lengthy command snipped ----> Start empty. ----> (def s nil) 0 1 2 3 4 5 ----> (def s (partition-by-with-seq alength (map byte-array [100000000 100000000 100000000 200000000]))) 0 1 2 3 4 5 ----> Drop head, get rest. ----> (def s (rest s)) 0 1 2 3 ----> No references. Memory freed. nil user=> (do ...) ; lengthy command snipped ----> Start empty. ----> (def s nil) 0 1 2 3 4 5 ----> (def s (partition-by-without-seq alength (map byte-array [100000000 100000000 100000000 200000000]))) 0 1 2 3 4 5 ----> Drop head, get rest. ----> (def s (rest s)) 0 ----> Head group items are hold? Realise rest. ----> (def s (seq s)) 0 1 2 3 ----> References gone. Memory freed. nil This is inline with my expectations purely from the definition (or rather docstring) of drop-while. Sincerely Meikel -- 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