unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
To: Guile User <guile-user@gnu.org>
Subject: goops speedups
Date: Sat, 10 Oct 2020 17:16:13 +0200	[thread overview]
Message-ID: <CAGua6m0y79Z-ZaHG1gAdANXYOVqTEyrWSoPzBhuuHEe-_jCG5g@mail.gmail.com> (raw)

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	other threads:[~2020-10-10 15:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-10 15:16 Stefan Israelsson Tampe [this message]
2020-10-10 20:12 ` goops speedups Linus Björnstam

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=CAGua6m0y79Z-ZaHG1gAdANXYOVqTEyrWSoPzBhuuHEe-_jCG5g@mail.gmail.com \
    --to=stefan.itampe@gmail.com \
    --cc=guile-user@gnu.org \
    /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).