[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fast string and number output to a stream
In article <email@example.com> firstname.lastname@example.org (Karsten Poeck) writes:
> What is the fastest way of writing strings and numbers to a stream? None
> of the ways I have tried seems to be much faster than simply using format.
(defun save-a-string (string function value stream)
(declare (ignore stream))
(dovector (char string)
(when (char= char #\")
(funcall function value #\\))
(funcall function value char)
(defun save-a-string-to-an-open-stream (string stream)
(save-a-string string a b stream)))
;(save-a-string-to-an-open-stream "ddddd" *standard-output*)
I have something like this for fixnums too, but you might as well call
print-object for numbers
Fixnums are pretty easy, but floats are a bit harder. I have some code
that does pretty well for floats.
Another thing to try is FORMATTER. In some Lisp's, like Allegro, it's
really just a call to format, but in MCL it looks like its trying to do the
right thing. I haven't timed it though.
You should also try WRITE.
BBN STC Work Phone: 617-873-3160
10 Moulton St. Home Phone: 617-643-0157
Mail Stop 6/4c FAX: 617-873-3776
Cambridge MA 02138