Greetings, and thank you so much for bringing this to my attention!  I
have committed a fix to branch 2_7_2pre, which will be in the
forthcoming debian package being built now.

Right now read-sequence loops over read-byte when appropriate, so could
be accelerated further with fread, but I doubt you will be able to see
much difference.  If using fread, we will have to duplicate the logic in
read-byte concerning the stream-element-type, but that is just ugly and
could be done.  One thing I've always wanted in GCL is an interface to
my favorite Linux file I/O facility, mmap.

Take care,

Raymond Toy <[email protected]> writes:

> 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.
>
> &#8203;
>

-- 
Camm Maguire                                        [email protected]
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah

Reply via email to