Re: Reasons to choose CLISP over other free implementations



Juho Snellman <jsnell@xxxxxx> writes:

(The code path for the non-constant cases of MAKE-INSTANCE is very much
unoptimized in SBCL. That it has not been optimized is probably due to
few people using that case in practice. At least I've never had anyone
report MAKE-INSTANCE with non-constant class or initarg names as a
bottleneck in their program before this.)

I have been bitten by this. Maybe one year ago I profiled my PDE solver
Femlisp and found that I lose quite a lot while making small matrix
instances. My workaround in three low-level routines was the following
rewrite (?2 is a macro choosing the second argument, LRET returns the last
local variable):

(defmethod zeros (n &optional (m n) (type 'double-float))
"Returns nxn or (if m is provided) nxm zeros. The value is freshly
allocated."
(?2 (make-instance (standard-matrix type) :nrows n :ncols m)
;; this branch avoids calling make-instance with keyword arguments on
;; a class unknown at compile time, because this is a performance
;; problem for several CL implementations
(lret ((result (make-instance (standard-matrix type))))
(with-slots (store nrows ncols) result
(setf nrows n ncols m
store (make-array (* n m) :element-type type
:initial-element (coerce 0 type)))))))
Yours,
Nicolas
.