On 4/8/26 9:21 AM, Raymond Toy wrote:
I have this routine:
|(defun slurp-bytes (filename) "Return the entire contents of FILENAME
as a (unsigned-byte 8) vector. Results are cached in *bytes-cache* so
each file is read only once." (or (gethash filename *bytes-cache*)
(setf (gethash filename *bytes-cache*) (with-open-file (s filename
:direction :input :element-type '(unsigned-byte 8)) (let* ((len
(file-length s)) (buf (make-array len :element-type '(unsigned-byte
8)))) (read-sequence buf s) buf))))) |
When reading maxima.info-1 (1030671 bytes), it takes a very long time
(several seconds). Is there anyway to speed this up? I would have
expected reading a bunch of bytes from a file via read-sequence would
be very fast.
Some googling pointed me to |si:fread|. It makes |slurp-bytes| really
fast taking tiny fractions of a sec to read i a 1 MB file. Having
|read-sequence| use |si:fread| for element types of |character| or
|(unsigned-byte 8)| would be a really good thing.
​