From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.user Subject: Re: goops speedups Date: Sat, 10 Oct 2020 22:12:03 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23489"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.3.0-407-g461656c-fm-20201004.001-g461656c6 To: "Stefan Israelsson Tampe" , "Guile User" Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Oct 10 22:13:00 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kRLEi-0005zv-Eo for guile-user@m.gmane-mx.org; Sat, 10 Oct 2020 22:13:00 +0200 Original-Received: from localhost ([::1]:60638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRLEh-0003lA-D8 for guile-user@m.gmane-mx.org; Sat, 10 Oct 2020 16:12:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRLEE-0003kn-LL for guile-user@gnu.org; Sat, 10 Oct 2020 16:12:31 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:43013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRLEC-0003p9-8u for guile-user@gnu.org; Sat, 10 Oct 2020 16:12:30 -0400 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 74B855C0092; Sat, 10 Oct 2020 16:12:25 -0400 (EDT) Original-Received: from imap1 ([10.202.2.51]) by compute6.internal (MEProxy); Sat, 10 Oct 2020 16:12:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.se; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type:content-transfer-encoding; s=fm1; bh=XbVDk pUgq/ymnApjpkDWY5KuCyVuTTNGbrBamxzbv84=; b=M1qxdM/+sxMGnpOMD3GwS fAYoeiKChQY40zjN2w147VsbA4+JPqeqYeqq7gAimFMPt385X128EaUr1v4djxZb x2COPpN84GA8nLxDBjq+utlKYzLiJVN/WASU5W+9j5fU6Jy6dKPF0BTlPDy0N5Ru 3FriAlEiKQgYGcVSOvgyMWxQRqcPrMJew8E+o3miC2wzVcBdmzfHRlHg068zK23S 3LdqyxToPIDsCS4pudLqRCDGxJtk6kLFLvVp7QGW7tA6M3iFl5euZaGGWpW0sP2W 4pXB1xemfnC362pmen3/uA4/nT5SSPts5Qo0EQ2V6kkLWWLYqChOKRoJXWX7g38k g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=XbVDkpUgq/ymnApjpkDWY5KuCyVuTTNGbrBamxzbv 84=; b=Rs0dTFTHXAmk2r6B67qeln6HSu/yTNsBhrCZ+qnlYvRtdrccNDKXBxOd/ LEmIrPHjbJvR2od33fa6Rjn3YtgQPxPHwgDrwSEDKTw3Xu/60fwIqPkqvquE3hc1 5SpIZ6yDaHKpisAcF/7vJixyyd0i/NRUjBydDBIREHYyrbL64C7f9xhXfQccCP1A rEsFPZInjm3EhGonKjkykjketzyLMjVRLnJKBpbRX5x/Ve5fz11TZvhS731coFNZ ARdGEyWsKl6X6m+q6CRbtZ4TiL5D6kY90L9FtsN/Kv+PMgc3g/pRhrs3+Ta8LqFM wQ/wJu9yPGTVCvtF4LJ4odMXj4j/A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrheefgddugeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpefnihhn uhhspgeujhpnrhhnshhtrghmuceolhhinhhushdrihhnthgvrhhnvghtsehfrghsthhmrg hilhdrshgvqeenucggtffrrghtthgvrhhnpeekleevieevleejffetieeltdelkeevtedu heefheduieffffdttdegjeeihedtjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehlihhnuhhsrdhinhhtvghrnhgvthesfhgrshhtmhgrihhl rdhsvg X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 03C7BC200A5; Sat, 10 Oct 2020 16:12:24 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: Received-SPF: pass client-ip=66.111.4.27; envelope-from=linus.internet@fastmail.se; helo=out3-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/10 16:12:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16974 Archived-At: Good idea. However: There are loads of data structures that don't do eff= icient random access. Lists, of course, but also fectors, where going do= wn 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 n= o or very minor fixes. The coroutine generators should be done using del= imited continuations though. --=20 Linus Bj=C3=B6rnstam On Sat, 10 Oct 2020, at 17:16, Stefan Israelsson Tampe wrote: > Dear all, >=20 > Consider the following code >=20 > (define (f x) > (let lp ((i 0) (s 0)) > (if (< i (len x)) > (lp (+ i 1) (+ (get x i) s)) > s))) >=20 > Not an uncommon code. The problem is you should be able speed up the l= oop > if len and get is generalized procedures by doing the dispatch once li= ke > this >=20 > (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)))) >=20 > The question is if we have such an interface or similar or if we shoul= d > request that we get such a feature from the guile overlords. >=20 > Regards > Stefan >