[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
goops speedups
From: |
Stefan Israelsson Tampe |
Subject: |
goops speedups |
Date: |
Sat, 10 Oct 2020 17:16:13 +0200 |
Dear all,
Consider the following code
(define (f x)
(let lp ((i 0) (s 0))
(if (< i (len x))
(lp (+ i 1) (+ (get x i) s))
s)))
Not an uncommon code. The problem is you should be able speed up the loop
if len and get is generalized procedures by doing the dispatch once like
this
(define (f x)
(let ((-len (find-dispatch len x))
(-get (find-dispatch get x)))
(let lp ((i 0) (s 0))
(if (< i (-len x))
(lp (+ i 1) (+ (-get x i) s))
s))))
The question is if we have such an interface or similar or if we should
request that we get such a feature from the guile overlords.
Regards
Stefan
- goops speedups,
Stefan Israelsson Tampe <=