On Sun, May 29, 2011 at 9:17 AM, bOR_ <boris.sch...@gmail.com> wrote:

> Is there something obvious I am missing when aset in clojure 1.3-alpha8
> won't work for shorts. aset-shorts does work, but way slower than I'd
> expect. There is also an order of magnitude difference in speed between aset
> ^ints and aset-int.
>
> I've looked at the source of amap (which was the first thing to give me
> problems with shorts), and from there came to writing the expanded amap
> macro out, and using aset-shorts rather than aset to get shorts working. I'm
> however stuck at looking at the source of aset and understanding how I can
> make that work with shorts.
>
> Related (now that I have the floor anyway), should I still be messing with
> java arrays in clojure 1.3, or would a vector of primitives be as fast?
>

aset-xxxx usage is not correct. Always use aset.

(let [^shorts as (make-array Short/TYPE 10)]
  (aset as 0 (short 1)))

Works fine.

Proper use of Java arrays is idiomatic for the forseeable future as far as I
can tell. Vectors of primitives are more efficient, but there's work to be
done for them to approach Java arrays in perf.

David

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

Reply via email to