From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.devel Subject: python-on-guile Date: Sat, 19 Feb 2022 20:36:39 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000ed86ff05d8641e92" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22297"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sat Feb 19 20:37:41 2022 Return-path: Envelope-to: guile-devel@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 1nLVY4-0005aJ-UA for guile-devel@m.gmane-mx.org; Sat, 19 Feb 2022 20:37:41 +0100 Original-Received: from localhost ([::1]:56814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLVY3-0006vM-S7 for guile-devel@m.gmane-mx.org; Sat, 19 Feb 2022 14:37:39 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLVXR-0006vC-8s for guile-devel@gnu.org; Sat, 19 Feb 2022 14:37:01 -0500 Original-Received: from [2607:f8b0:4864:20::530] (port=41859 helo=mail-pg1-x530.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLVXP-0005ja-0g for guile-devel@gnu.org; Sat, 19 Feb 2022 14:37:00 -0500 Original-Received: by mail-pg1-x530.google.com with SMTP id f8so10731284pgc.8 for ; Sat, 19 Feb 2022 11:36:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=EZVTR9F74orh0pThyW8yoNdAe7BBjG0U4i+LSSNM+WY=; b=M4ecKD8h95JD2uktCXsu9JNaCb+2c4cXBDCiqHPXl6rQC7L5+13dA+hticjy27HVOv +c3UvPT2enrjRbi/WAAJ6Kj3+gljlR70X8t7/qPlvwsoZZYsuvTNCVpiH8ryfZWOgszm Cd1UxC/zaFVkrhyZyT9fc0Shp0id/NWvwZSrHvsLw2SnsWqlWvkbWsGGj5y3kvl0FLzu llBpXgTLFoVpZPGPrtRhEOknabHQRvrUhmi9pmqW4mbzg133toyfTtfRm7ZyqQFeD3Z3 pWVFim46fHY5i+01ye8mMrcd3/AiZ3keGXCbrdjkzyJMlytalNktkFimaI/37Tr1xpEm 5kTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=EZVTR9F74orh0pThyW8yoNdAe7BBjG0U4i+LSSNM+WY=; b=qTkCOSRutUtn9X2iRZCy3azPkIByg0xQro1nXYzve9mxhpdtgtmqbUJo36WwJpYtW7 oOBt8neWqQFjEF9Z0ElfcVCciJS8JeYKcD2hVXDR/nImRRoMUjbZH+5MB2ac1dVfocmI HIjV71Sn+17iGeAMmCM+Mr77nlFj3GcmQ3VWzblrnWAuYY6IjSC17XcjFljO3imoYrK2 CGak5FRPnlhheaxGAMQ+4i1MXpgs6Ycc3dit58/FDyV3UD55MWErGA9O8lDBpZIutrX0 HjS1SKV882/LJLHSYmpVNlR0p1ShkB5+2pmDZLkpxskPw0ZRk2c3Il5K1LnfUGrBY4kr 9lyA== X-Gm-Message-State: AOAM530zZG20161eSpsiFkk/+WUYYNZO/ywGO77E8k2UqqvJK8KGZkC7 rXn86OLNMylTF6CNx+z6KQmDBZ/L2eT1fP9tZIqlT2wIeKc= X-Google-Smtp-Source: ABdhPJzbyo66c4HeP+qkVy8JqFXPbm8GIzV6gjqkCnb8uvTUq2YNyGA2TZscqSorsGy/VXzU/j53rt8UyC6LQTiXR+c= X-Received: by 2002:a62:7e06:0:b0:4e0:f0f8:9b86 with SMTP id z6-20020a627e06000000b004e0f0f89b86mr13556026pfc.26.1645299410764; Sat, 19 Feb 2022 11:36:50 -0800 (PST) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::530 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=stefan.itampe@gmail.com; helo=mail-pg1-x530.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:21131 Archived-At: --000000000000ed86ff05d8641e92 Content-Type: text/plain; charset="UTF-8" i am now experimenting with the new generator infrastructure to see how much actual python on guile code is sped up. In the process I am optimizing a lot of stuff regarding python for loops. But some irritating things remain. My number 1 anger is that a iterator can throw an exception as a way to end a loop. And then at a final step all loop data has to be available so in a functional style you now need to have the catch frame that is internal. Currently we have the cludge of wither use known safe iterations, like over a list of values or a range or a known safe generator. More general code needs to play with a pletoria of set! actions in order to transfer data out of scope. Horrible!!! But what about this solution just make a generator that returns all values so that you can keep track of em and just issue the finishing command with it. (define internalGenerator (lambda () (pause) (catch 'StopIteration (lambda () (let lp ((s s0) ...) (return x ... s ...) (let ((xx (next I)) ...) (let ((x xx) ...) code ... (lp snew ...)))) (return 'finished) (lambda xxx (return 'finished)))))) We know that the generator over head in the loop is quite small just 3-4x the speediest loop guile perform. with this we get non set! operations that are very performant. But not only this we might get continue to work speedily as well --000000000000ed86ff05d8641e92 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
i am now experimenting with the new=C2=A0generator infrast= ructure to see how much actual python on guile code is sped up. In the proc= ess I am optimizing a lot of stuff regarding python for loops. But some irr= itating things remain.

My number 1 anger is that a itera= tor can throw an exception as a way to end a loop. And then at a final step= all loop data has to be available so in a functional style you now need to= have the catch frame that is internal.=C2=A0 Currently we have the cludge = of wither use known safe iterations, like over a list of values or a range = or a known safe generator. More general code needs to play with a pletoria = of set! actions in order to transfer data out of scope. Horrible!!!

But what about this solution just make a generator that r= eturns all values so that you can keep track of em and just issue the finis= hing=C2=A0command=C2=A0with it.

(define internalGe= nerator=C2=A0
=C2=A0 =C2=A0 (lambda ()
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(pause)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(ca= tch 'StopIteration
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 (lambda ()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let lp ((s s0) ...)
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (return x ... s ...)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((xx (next I)) = ...)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((x xx) ...)
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 code ...=C2=A0
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lp snew ...))))
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(return '= ;finished)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (lambda xxx (return 'finished))))))
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
We know that the genera= tor over head in the loop is quite small just 3-4x the speediest loop guile= perform. with this we get non set! operations that are very performant. Bu= t not only this we might get continue to work speedily as well







--000000000000ed86ff05d8641e92--