On Wednesday, 30 October 2013 18:44:47 UTC+8, Alice wrote: > Which one is preferred? > > .length needs to be type hinted, so more verbose. > The performance penalty of count is negligible in most cases. >
Doing a quick micro-benchmark with criterium I get: - .length at 5.5 ns - count at 50.0 ns i.e. both are very fast, but .length has a significant advantage if you are calling it a lot in performance-sensitive code. OTOH, count is much more generic since it can handle arbitrary sequences etc. Also count doesn't require type hints. You should definitely prefer count when writing most high level code. -- -- 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.