guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extremly slow for format & string-join


From: Ian Price
Subject: Re: Extremly slow for format & string-join
Date: Mon, 01 Apr 2013 13:55:48 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Nala Ginrut <address@hidden> writes:

> string-join is a common thing for text processing(include web develop).
> However, our powerful 'format' is not so efficient. I do think it's
> necessary to we spend some time on it.

As Mark says, format is a not very nice piece of code to read, or to
modify, so if you want it faster, it'll be on you to implement I'm
afraid.

One thing you might be interested in though, is Alex Shinn's fmt
library[0] (available on guildhall as wak-fmt), which is quite nice.

(import (wak fmt))

(define (repeat formatter n)
  ;; I could probably make this a little faster, if I knew the internal
  ;; representation of format combinators, and didn't build the list
  (apply-cat (make-list n formatter)))

(define (str* str n)
  ;; spends the bulk of its time in display
  (fmt #f (repeat str n)))

It is not as competitive as Mark's improvements to string-join (5/6
seconds versus 4/5 milliseconds), but it's a hell of a lot faster than
format, and it works on any arbitrary fmt formatter.

I think we can take this as bearing out the well known speed differences
of custom hardware/software (string-join) vs compilation (fmt) vs
interpretation (format). :)

0. http://synthcode.com/scheme/fmt
-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]