Re: Efficiency of arrays in LISP



JohnFredCee wrote:
Actually I had a similar more newbie - ish question relating to
SBCL/CMUCL: when passing small tuples (vectors, matrices for 3d and 2d
around) a lot - which is more efficent, small arrays, a struct or
multiple-values?

My guess was multiple values for the 2-3-4 tuples (they live in
registors or on the stack, don't they?) and small arrays of single
floats for the 9-16 tuples (matrices)..

I guess I should DISSASEMBLE and find out, rather than be lazy and ask
the group. Although the group might know of implementation gotchas that
I don't

I would expect multiple-values assuming that 1. you're not capturing
them with MULTIPLE-VALUE-LIST 2. the function providing them is
inlined.

If the function is not inlined, and the values are eg. double-floats,
every one is going to get heap-allocated separately, in which case it
_might_ be faster to allocate a specialized array and store them there.
No way to know without profiling, though.

Cheers,

-- Nikodemus Siivola

.