When you call seq on a collection, it returns an object of a custom type which implements ISeq interface. In some cases, this object also implements IChunkedSeq, which is a more performant version for cases when you need to iterate over the collection.
The rule whether collection returns object implementing ISeq or IChunkedSeq is an implementation detail, but it is obvious that chunked seqs will be supported by collections which keep data in 'chunks' internally. This is the case for vectors, as they keep the data in 32 item arrays. JW On Sun, Oct 20, 2013 at 5:36 PM, Tj Gabbour <t...@pentaside.org> wrote: > Hi! > > (I'm writing clojure-doc.org articles, so any help/corrections will help > others too.) > > Why is Clojure designed so that only vectors and `range` results are > chunked (when you seq them), and not other things? Did someone profile > Clojure programs, and these were the two hotspots? Or was it a matter of > being conservative, and I/O is less likely in seqs based on vectors/ranges? > > > Thanks, > Tj > > PS: My assumptions (from grepping the code and reading Chas Emerick's > explanation): > > * Only non-empty vectors & `range` calls become chunked when you call > seq. (Aside from, of course, user-defined chunked sequences.) > > * Chunkiness is opt-in. Functions like map manually propagate > chunking. Joy of Clojure's `seq1` turns off chunkiness because it > enforces a seq based on lists. > > -- > -- > 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/groups/opt_out. > -- -- 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/groups/opt_out.