[Top][All Lists]

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

Re: goops speedups

From: Linus Björnstam
Subject: Re: goops speedups
Date: Sat, 10 Oct 2020 22:12:03 +0200
User-agent: Cyrus-JMAP/3.3.0-407-g461656c-fm-20201004.001-g461656c6

Good idea. However: There are loads of data structures that don't do efficient 
random access. Lists, of course, but also fectors, where going down the tree on 
each element access has a lot higher overhead than going through it 
sequentially. A generator based approach to iterating through them would 
potentially be more efficient for the case when you want to go from 
0..((find-dispatch len x) x).

Guile lacks srfi-158, bit the reference implementation should run with no or 
very minor fixes. The coroutine generators should be done using delimited 
continuations though.
  Linus Björnstam

On Sat, 10 Oct 2020, at 17:16, Stefan Israelsson Tampe wrote:
> 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

reply via email to

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