17:54:16sjlmy brain isn't working today. If I have a sequence S and I want to get a fresh vector containing its elements, is there a better way than (map 'vector 'identity s)?
17:54:46sjl(coerce (copy-seq s) 'vector) would work, but if s is a list it would needlessly cons an intermediate list
19:18:55Shinmeraoh, right, I missed that message, sorry.
19:19:33Shinmerabut as phoe pointed out copying a list to an array will incur a length check anyway because resizing many times would be much more costly than counting precisely once.
20:33:01_deaththere's also :initial-contents, but has the same issue with length
20:34:01Shinmeralast I looked at it for whatever reason make-array/replace was faster than initial-contents
20:34:19Shinmeramight have changed/be different on non-sbcl
20:39:55_deathbut confirmed here.. for a 1m elements simple-vector it takes about 3.802 ms for initial-contents vs. 3.236 ms for replace
20:42:00Shinmeramy guess is that supplying initial-contents hits a slow path on transforms.
20:43:23_deathtakes around the same time with speed 3 though
20:43:38pjbWhy not (defun make-array (…) … (when initial-contents (replace array initial-contents))) which should be as fast? (modulo recursion into the dimensions).
20:53:58aethIt depends on what the initial-contents are, of course. If they're a literal list, I think you hit the fast path, at least on SBCL