On Tue, Feb 15, 2011 at 3:52 AM, Marko Topolnik <marko.topol...@gmail.com> wrote: >> 4. Unless you're using 1.3 or later, put the innermost loop in a >> single function and try to avoid calling sub-functions, except for >> operators like + that can get inlined. > > This is interesting, can you be more specific about this point -- what > exactly do we need to avoid? Calls that force the boxing of > primitives?
All non-inlined function calls done frequently in innermost loops. You can use definline to make your own inlined functions -- or just use defmacro. > Is really any call that isn't inlined that expensive? Yes, unfortunately. You saw the numbers. :) > And what specific improvements does 1.3 bring? To coin a phrase, "that's been discussed to death on this list". Actually I got socked with that response when I asked a similar question and what I've heard has been awfully vague for the most part; mostly, the syntaxes for fast checked primitive, fast unchecked primitive, and slower checked boxed potentially-bignum, arithmetic are being rearranged (somewhat gratuitously, IMO), and a syntax for checked boxed non-bignum math is being added (I'm not sure of a real use-case for this). Oh, and we'll finally be able to call functions with long and double primitive args and not just boxed numbers. :) > I am very interested in writing code that's both optimal and as idiomatic as > possible. I don't think the loop in diagonal-sum-3 (see other thread) is really "non-idiomatic", /for code that needs speed/. >> 10. Watch for reflection warnings when using arrays. Don't bother with >> aset-int and friends either. > > What do you mean by not bothering with aset-int? I think in 1.0 they may have been faster with primitive arrays, but not with local primitives in 1.1 and later; they're slower. -- 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