[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to read integers from file faster?
From: |
Mike Gran |
Subject: |
Re: How to read integers from file faster? |
Date: |
Fri, 30 Aug 2013 22:46:51 -0700 (PDT) |
> From: Darren Hoo <address@hidden>
>It is way too slow to read numbers from a file simply by using `read'
The problem mostly lies in dealing with the locale or doing utf-8
conversion. Also, your code creates and destroys a lot of strings.
You could push data through much more quickly if it were binary
and if you didn't create new objects.
(define (read-test1)
(let* ((p (open-input-file "rnd.txt"))
(buf (make-bytevector 10 0)))
(let lp ((i (get-bytevector-n! p buf 0 10)))
(if (not (eof-object? i))
(lp (get-bytevector-n p 10))))))
But, alas, knowing that isn't really a solution to your problem.
-Mike