Indeed, I modified the macroexpanded form into:

(cl-block nil
  (let* ((--cl-var-- (number-sequence 0 130000))
         i
         pairs
         pairs-end)
    (while (consp --cl-var--)
      (setq i (car --cl-var--))
      (let ((v (list (cons (number-to-string i) i))))
        (if (null pairs-end)
            (setq pairs v pairs-end (last pairs))
          (setq pairs-end (setcdr pairs-end v))))
      (setq --cl-var-- (cdr --cl-var--)))
    (length pairs)))

and it runs near instantaneously.

I'd guess the fix would be applied in `cl--parse-loop-clause`? Perhaps Stefan could give some pointers?


On Sat, Apr 7, 2018 at 11:12 PM, Clément Pit-Claudel <cpitclaudel@gmail.com> wrote:
On 2018-04-08 01:56, Tianxiang Xiong wrote:
> Yikes--wasn't expecting that. Similar code in SBCL runs nearly instantaneously.

Indeed, fixing the implementation would be nice.  It shouldn't be too hard to keep a reference to the last `cons' of `pairs' and to append to that using setcdr.

Clément.