Advantages exist, ClojureScript and Clojure both use the most efficient
equality check during key lookup in maps.

On Saturday, October 11, 2014, Colin Fleming <colin.mailingl...@gmail.com>
wrote:

> Does this mean that keywords don't have any efficiency advantages over
> strings when used as map keys?
>
> On 12 October 2014 02:25, David Nolen <dnolen.li...@gmail.com
> <javascript:_e(%7B%7D,'cvml','dnolen.li...@gmail.com');>> wrote:
>
>> As already mentioned use identical? In ClojureScript you must use
>> keyword-identical? for fast comparisons.
>>
>>
>> On Friday, October 10, 2014, Jony Hudson <jonyepsi...@gmail.com
>> <javascript:_e(%7B%7D,'cvml','jonyepsi...@gmail.com');>> wrote:
>>
>>> Hi All,
>>>
>>>  I've been optimising a piece of code lately, and have come to wonder
>>> about the performance of keyword comparison. Specifically, I'm not sure
>>> whether the performance I'm seeing is what is expected. The data structures
>>> page on clojure.org [1] indicates that keywords "provide very fast
>>> equality tests". If I micro-benchmark with criterium, then I find the
>>> following:
>>>
>>> As a baseline, comparing integers with `(= 0 1)` takes around 4ns.
>>>
>>> Comparing keywords with `(= :plus :minus)` takes around 30ns.
>>>
>>> This is about the same amount of time it takes to compare strings, `(=
>>> "plus" "minus")`, which comes in at about 25ns.
>>>
>>> This surprised me, as I would have guessed that "fast" would have been
>>> closer to the integer performance than the string performance. It's worth
>>> saying that I don't know a lot about benchmarking, but I do have some
>>> "real" code that's performance depends heavily on comparisons, and it seems
>>> to line up performance-wise with these micro-benchmarks.
>>>
>>> So, am I doing something silly (like I don't know about the fast = for
>>> keywords)? Or, are my expectations wrong, and this is about how long "fast"
>>> should be? Or is there a performance bug lurking?
>>>
>>> I'm using Clojure 1.6.0 (but have tried 1.5.0 and 1.7.0-alpha1 with
>>> similar results).
>>> x86_64 Mac OS X 10.9.5 4 cpu(s)
>>>
>>> Java HotSpot(TM) 64-Bit Server VM 25.5-b02
>>>
>>> Thanks in advance for any input,
>>>
>>>
>>> Jony
>>>
>>> [1] http://clojure.org/data%5Fstructures
>>>
>>> --
>>> 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/d/optout.
>>>
>>  --
>> 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
>> <javascript:_e(%7B%7D,'cvml','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
>> <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@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
>> <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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
> <javascript:_e(%7B%7D,'cvml','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
> <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@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
> <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');>.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/d/optout.

Reply via email to