From: "Linus Björnstam" <linus.internet@fastmail.se>
To: "Stefan Israelsson Tampe" <stefan.itampe@gmail.com>,
"Guile User" <guile-user@gnu.org>
Subject: Re: goops speedups
Date: Sat, 10 Oct 2020 22:12:03 +0200 [thread overview]
Message-ID: <f0fc5186-9ef8-4da2-9dcc-d9e5bc56a2c1@www.fastmail.com> (raw)
In-Reply-To: <CAGua6m0y79Z-ZaHG1gAdANXYOVqTEyrWSoPzBhuuHEe-_jCG5g@mail.gmail.com>
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
>
prev parent reply other threads:[~2020-10-10 20:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-10 15:16 goops speedups Stefan Israelsson Tampe
2020-10-10 20:12 ` Linus Björnstam [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f0fc5186-9ef8-4da2-9dcc-d9e5bc56a2c1@www.fastmail.com \
--to=linus.internet@fastmail.se \
--cc=guile-user@gnu.org \
--cc=stefan.itampe@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).