Hi,

On Mon, Feb 4, 2013 at 12:13 PM, Paul Stadig <p...@stadig.name> wrote:

> On Sunday, February 3, 2013 9:56:49 PM UTC-5, puzzler wrote:
>>
>> In these examples, the map/record is freshly created each time through
>> the loop, so caching should not be a factor.
>>
>
> Good point. So maybe it's not the caching :).
>

No Paul, you were right: it's the caching. The map is seen as constant and
its creation is hoisted outside of the loop so hash is called 1e7 times on
the same map object. While a new record is created at each iteration.

If you rewrite  (time (dotimes [n 10000000] (hash (A. "a" 3)))) as  (time
(dotimes [n 10000000] (hash #user.A["a" 3]))) you get a single record
instance -- but still no caching on records.

In my patch to fix the hashing caching (or lack of) I didn't cover records
because it's more involved: it requires changes to the compiler because we
need to add new fields to the record to hold the cached value -- fields
that must not be part of the constructor.

Christophe

-- 
On Clojure http://clj-me.cgrand.net/
Clojure Programming http://clojurebook.com
Training, Consulting & Contracting http://lambdanext.eu/

-- 
-- 
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.


Reply via email to