When I was putting together lessons to teach Clojure, I was analyzing texts
from Gutenberg and doing things like counting the number of words, and the
frequency and distribution of words, and things like that, and "partial"
was noticeably slower. FWIW.

On Sun, Oct 20, 2019 at 11:23 PM Alex Engelberg <
alex.benjamin.engelb...@gmail.com> wrote:

> All functions returned by a given arity of partial or comp are of the same
> Java class under the hood, whereas defining an anonymous function always
> generates a new class, and I've heard that fewer classes can result in
> better performance from a JIT perspective. But I'm just speculating and
> haven't actually run the benchmarks. So, [citation needed].
>
> From a more practical perspective: I always prefer to give my anonymous
> functions names (e.g. `(fn foo [x])`, not `(fn [x])`), so that the stack
> traces are a bit more self-explanatory, but partial and comp don't let you
> do that. Although sometimes the added readability of a higher-order
> function outweighs that concern.
>
> On Sun, Oct 20, 2019 at 2:55 PM John D. Hume <duelin.mark...@gmail.com>
> wrote:
>
>> It's been a long time since I looked at this, but as of a few years ago,
>> the biggest noticeable performance detriment of comp or partial was likely
>> to come if you pass enough args to hit a "& args" overload, which requires
>> creating a fresh object array at each call, when the underlying function
>> being called has a non-"& args" arity.
>>
>> On one application I worked on, we preferred defining #(anonymous ...)
>> functions to some uses of higher order functions to avoid excessive
>> garbage-creation in some hot spots.
>>
>> This assumes you don't need primitive type-hint-level optimization.
>>
>> I wouldn't recommend sacrificing any clarity unless you've profiled and
>> found a real issue.
>>
>> definition of partial:
>>
>> https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2614
>>
>> definition of comp:
>>
>> https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2557
>>
>>
>> On Sun, Oct 20, 2019, 3:25 PM david hoyt <davidpaulh...@gmail.com> wrote:
>>
>>> Is there a performance benefit (or detriment) to creating partial
>>> functions? Other than the potential reduction of complexity, is there a
>>> difference between using partial & comp and defining new functions?
>>>
>>> --
>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/clojure/146f2a73-9887-4eba-89c6-815eed6841b1%40googlegroups.com
>>> .
>>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/clojure/CAKK7-VLE_TPdjBuf6g8n0hVLaiMeibS63wJ8UqGDKD1qGZ4T2A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/clojure/CAKK7-VLE_TPdjBuf6g8n0hVLaiMeibS63wJ8UqGDKD1qGZ4T2A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/clojure/CAMvaFAXa6Qhch%2B%2B-OCTVz399GCAiHJxxNM6VM%3Dak3hjVzkB1gw%40mail.gmail.com
> <https://groups.google.com/d/msgid/clojure/CAMvaFAXa6Qhch%2B%2B-OCTVz399GCAiHJxxNM6VM%3Dak3hjVzkB1gw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/CAJAnwPmLyqr6eg4VL_VZLjPotcN3yUOoV9gzg7ZW%3D5CMc%2Be2Yg%40mail.gmail.com.

Reply via email to