[racket] Super basic question about strings

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Nov 17 13:17:03 EST 2010

10 minutes ago, Matthias Felleisen wrote:
> 
> The bottleneck is format. [...]

The main bottleneck is using format with "~s" -- it's big enough to
shadow other changes.  IIRC, "~s" is implemented via a string port,
and if so, one reason for Neil's version being faster is that it
already outputs to a port so there's no need to create one for the
format.

BTW, another approach that keeps the speed of directly outputting the
text is to not do any IO until needed -- accumulate a list of all
outputs (without using "~s"s at this stage), then have a loop that
goes over it when it's time to produce the output.  This is
essentially what `scribble/text' is doing.  (Actually, it generalizes
it from list to arbitrary sexpr trees.)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.