Lispworks append is too slow
Hello all,Lispworks append is too slow.
Take a look at this code:
(defvar a (make-list 10000000))
(defvar b (make-list 10000000))
(defvar c )
(time (setf c (append a b)))
It's giving me this answer (and I compiled it)
User time = 3.468
System time = 0.091
Elapsed time = 4.027
Allocation = 120000096 bytes
Under SBCL it takes 0,001.
I was trying to rewrite this append, keeping the
last cons in a "pointer". But, it did not work.
Any clues?
Look at the code (it update two variables, thelist and the lastcons) :
(defstruct *ghost* )
(defmacro appendE (thelist lastcons element)
`(if (equal ,thelist nil) ; I am becoming a lisp programmer lol
(let () (setf ,lastcons (list (make-*ghost*))) (setf ,thelist (cons ,element ,lastcons)))
(if (typep ,lastcons '*ghost*)
(setf (car ,lastcons) ,element)
(let ((x (cons ,element nil))) (setf (cdr ,lastcons) x) (setf ,lastcons x))))
)
--
Mauricio Toro Bermudez
Estudiante de Ingeniería de Sistemas
Pontificia Universidad Javeriana, Colombia
Stagiare à l'Ircam
1, place Igor-Stravinsky 75004 Paris,
France de 2008 à 2009