unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* python-on-guile
@ 2019-06-14 18:06 Stefan Israelsson Tampe
  2019-06-22 21:07 ` python-on-guile Arne Babenhauserheide
  2019-06-26 18:45 ` python-on-guile Nala Ginrut
  0 siblings, 2 replies; 18+ messages in thread
From: Stefan Israelsson Tampe @ 2019-06-14 18:06 UTC (permalink / raw)
  To: guile-devel, Guile User

[-- Attachment #1: Type: text/plain, Size: 519 bytes --]

python on guile has reached quite far and now compiles a lot of the
standard python code base. The speed has not been of importance. Rather to
get good coopertion between guile scheme and python programs.

But it also define a scheme interface to the python functionalites and i'm
now trying to compile some documentation of this inteface. You can find
docs at http://www.c-lambda.se/python-on-guile.

source code is at,
https://gitlab.com/python-on-guile/python-on-guile/

This is a work in progress.

Happy hacking!!

[-- Attachment #2: Type: text/html, Size: 775 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: python-on-guile
  2019-06-14 18:06 python-on-guile Stefan Israelsson Tampe
@ 2019-06-22 21:07 ` Arne Babenhauserheide
  2019-06-26 18:45 ` python-on-guile Nala Ginrut
  1 sibling, 0 replies; 18+ messages in thread
From: Arne Babenhauserheide @ 2019-06-22 21:07 UTC (permalink / raw)
  To: guile-devel; +Cc: Guile User

[-- Attachment #1: Type: text/plain, Size: 489 bytes --]


Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:

> python on guile has reached quite far and now compiles a lot of the
> standard python code base. The speed has not been of importance. Rather to
> get good coopertion between guile scheme and python programs.

That sounds awesome! Thank you for sharing!

> https://gitlab.com/python-on-guile/python-on-guile/
> Happy hacking!!

Happy Hacking!
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1076 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: python-on-guile
  2019-06-14 18:06 python-on-guile Stefan Israelsson Tampe
  2019-06-22 21:07 ` python-on-guile Arne Babenhauserheide
@ 2019-06-26 18:45 ` Nala Ginrut
  1 sibling, 0 replies; 18+ messages in thread
From: Nala Ginrut @ 2019-06-26 18:45 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: Guile User, guile-devel

Thanks for the work! I appreciate it!

On Sat, Jun 15, 2019 at 3:05 AM Stefan Israelsson Tampe
<stefan.itampe@gmail.com> wrote:
>
> python on guile has reached quite far and now compiles a lot of the standard python code base. The speed has not been of importance. Rather to get good coopertion between guile scheme and python programs.
>
> But it also define a scheme interface to the python functionalites and i'm now trying to compile some documentation of this inteface. You can find docs at http://www.c-lambda.se/python-on-guile.
>
> source code is at,
> https://gitlab.com/python-on-guile/python-on-guile/
>
> This is a work in progress.
>
> Happy hacking!!



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Python-on-guile
@ 2021-04-23 15:00 Mikael Djurfeldt
  2021-04-23 20:41 ` Python-on-guile Linus Björnstam
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Mikael Djurfeldt @ 2021-04-23 15:00 UTC (permalink / raw)
  To: guile-user, guile-devel

Hi,

Yesterday, Andy committed new code to the compiler, some of which concerned
skipping some arity checking.

Also, Stefan meanwhile committed something called "reworked object system"
to his python-on-guile.

Sorry for coming with unspecific information (don't have time to track down
the details) but I noticed that my benchmark script written in Python, and
which computes the 20:th Ramanujan number, now runs 60% faster than before
these changes.

This means that python-on-guile running on guile3 master executes python
code only 2.6 times slower than the CPython python3 interpreter itself. :-)

Have a nice weekend all,
Mikael


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
@ 2021-04-23 20:41 ` Linus Björnstam
  2021-04-24 10:04 ` Python-on-guile Mikael Djurfeldt
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 18+ messages in thread
From: Linus Björnstam @ 2021-04-23 20:41 UTC (permalink / raw)
  To: Mikael Djurfeldt, guile-user, guile-devel

Hurra!

I noticed a couple.of weeks ago that declarative modules made it possible for me to stop using define-syntax-rule to force stupid inlining of code. The cross module inlining branch will make that even nicer. I can write cleaner code and get better error messages :)

Guile has been going in a very nice direction for some time!
-- 
  Linus Björnstam

On Fri, 23 Apr 2021, at 17:00, Mikael Djurfeldt wrote:
> Hi,
> 
> Yesterday, Andy committed new code to the compiler, some of which 
> concerned skipping some arity checking.
> 
> Also, Stefan meanwhile committed something called "reworked object 
> system" to his python-on-guile.
> 
> Sorry for coming with unspecific information (don't have time to track 
> down the details) but I noticed that my benchmark script written in 
> Python, and which computes the 20:th Ramanujan number, now runs 60% 
> faster than before these changes.
> 
> This means that python-on-guile running on guile3 master executes 
> python code only 2.6 times slower than the CPython python3 interpreter 
> itself. :-)
> 
> Have a nice weekend all,
> Mikael
> 



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
  2021-04-23 20:41 ` Python-on-guile Linus Björnstam
@ 2021-04-24 10:04 ` Mikael Djurfeldt
  2021-04-24 11:26   ` Python-on-guile Stefan Israelsson Tampe
  2021-04-25 10:18 ` Python-on-guile Stefan Israelsson Tampe
  2021-04-27 12:29 ` Python-on-guile Nala Ginrut
  3 siblings, 1 reply; 18+ messages in thread
From: Mikael Djurfeldt @ 2021-04-24 10:04 UTC (permalink / raw)
  To: guile-user, guile-devel

(I should perhaps add that my script doesn't benchmark the object system
but rather loops, conditionals and integer arithmetic.)

Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com> skrev:

> Hi,
>
> Yesterday, Andy committed new code to the compiler, some of which
> concerned skipping some arity checking.
>
> Also, Stefan meanwhile committed something called "reworked object system"
> to his python-on-guile.
>
> Sorry for coming with unspecific information (don't have time to track
> down the details) but I noticed that my benchmark script written in Python,
> and which computes the 20:th Ramanujan number, now runs 60% faster than
> before these changes.
>
> This means that python-on-guile running on guile3 master executes python
> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>
> Have a nice weekend all,
> Mikael
>
>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-24 10:04 ` Python-on-guile Mikael Djurfeldt
@ 2021-04-24 11:26   ` Stefan Israelsson Tampe
  2021-04-24 12:59     ` Python-on-guile Stefan Israelsson Tampe
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-24 11:26 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]

Pro tip, when running this on guile the scheme code that it compilse to is
located in log.txt.
If you ,opt the resulting code in a guile session you might be able to
pinpoint issues that
delays the code execution.

On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

> (I should perhaps add that my script doesn't benchmark the object system
> but rather loops, conditionals and integer arithmetic.)
>
> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com> skrev:
>
>> Hi,
>>
>> Yesterday, Andy committed new code to the compiler, some of which
>> concerned skipping some arity checking.
>>
>> Also, Stefan meanwhile committed something called "reworked object
>> system" to his python-on-guile.
>>
>> Sorry for coming with unspecific information (don't have time to track
>> down the details) but I noticed that my benchmark script written in Python,
>> and which computes the 20:th Ramanujan number, now runs 60% faster than
>> before these changes.
>>
>> This means that python-on-guile running on guile3 master executes python
>> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>>
>> Have a nice weekend all,
>> Mikael
>>
>>

[-- Attachment #2: Type: text/html, Size: 1931 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-24 11:26   ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-24 12:59     ` Stefan Israelsson Tampe
  2021-04-24 14:41       ` Python-on-guile Stefan Israelsson Tampe
  2021-04-25 10:54       ` Python-on-guile Dr. Arne Babenhauserheide
  0 siblings, 2 replies; 18+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-24 12:59 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

Actually changing in (language python compile),

(define (letec f)
  (let/ec x (f x))))

To

(define-syntax-rule (letec f)
  (let/ec x (f x))))

Actually lead to similar speeds as python3.



On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> Pro tip, when running this on guile the scheme code that it compilse to is
> located in log.txt.
> If you ,opt the resulting code in a guile session you might be able to
> pinpoint issues that
> delays the code execution.
>
> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
> wrote:
>
>> (I should perhaps add that my script doesn't benchmark the object system
>> but rather loops, conditionals and integer arithmetic.)
>>
>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com> skrev:
>>
>>> Hi,
>>>
>>> Yesterday, Andy committed new code to the compiler, some of which
>>> concerned skipping some arity checking.
>>>
>>> Also, Stefan meanwhile committed something called "reworked object
>>> system" to his python-on-guile.
>>>
>>> Sorry for coming with unspecific information (don't have time to track
>>> down the details) but I noticed that my benchmark script written in Python,
>>> and which computes the 20:th Ramanujan number, now runs 60% faster than
>>> before these changes.
>>>
>>> This means that python-on-guile running on guile3 master executes python
>>> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>>>
>>> Have a nice weekend all,
>>> Mikael
>>>
>>>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-24 12:59     ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-24 14:41       ` Stefan Israelsson Tampe
  2021-04-24 15:19         ` Python-on-guile Stefan Israelsson Tampe
  2021-04-25 10:54       ` Python-on-guile Dr. Arne Babenhauserheide
  1 sibling, 1 reply; 18+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-24 14:41 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 2144 bytes --]

To note is that 'continue' is killing performance for python-on-guile
programs, so by changing the
code to not use continue lead to python-on-guile running twice the speed of
python3. The reason is that
the while loop is used as
(while (...)
   (let/ec continue
        ...))

And the let/ec is probably not optimally compiled. Python-on-guile will
check the loop for continue usage and if not then it will skip the let/ec.

I attached the code not using continue

On Sat, Apr 24, 2021 at 2:59 PM Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> Actually changing in (language python compile),
>
> (define (letec f)
>   (let/ec x (f x))))
>
> To
>
> (define-syntax-rule (letec f)
>   (let/ec x (f x))))
>
> Actually lead to similar speeds as python3.
>
>
>
> On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
> stefan.itampe@gmail.com> wrote:
>
>> Pro tip, when running this on guile the scheme code that it compilse to
>> is located in log.txt.
>> If you ,opt the resulting code in a guile session you might be able to
>> pinpoint issues that
>> delays the code execution.
>>
>> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
>> wrote:
>>
>>> (I should perhaps add that my script doesn't benchmark the object system
>>> but rather loops, conditionals and integer arithmetic.)
>>>
>>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com> skrev:
>>>
>>>> Hi,
>>>>
>>>> Yesterday, Andy committed new code to the compiler, some of which
>>>> concerned skipping some arity checking.
>>>>
>>>> Also, Stefan meanwhile committed something called "reworked object
>>>> system" to his python-on-guile.
>>>>
>>>> Sorry for coming with unspecific information (don't have time to track
>>>> down the details) but I noticed that my benchmark script written in Python,
>>>> and which computes the 20:th Ramanujan number, now runs 60% faster than
>>>> before these changes.
>>>>
>>>> This means that python-on-guile running on guile3 master executes
>>>> python code only 2.6 times slower than the CPython python3 interpreter
>>>> itself. :-)
>>>>
>>>> Have a nice weekend all,
>>>> Mikael
>>>>
>>>>

[-- Attachment #2: ram.py --]
[-- Type: text/x-python, Size: 1778 bytes --]

#  ramanujan.py -- Compute the N:th Ramanujan number
#  
#  Copyright (C) 2018-2021 Mikael Djurfeldt
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# Version 2

# return the N:th Ramanujan number (sum of two cubes in more than one way)
#
def ramanujan (n):
    w = 0 # Ramanujan number candidate
    b0 = 1 # first second term to try
    while n > 0:
        w += 1 # try next candidate

        # increase initial b0 until 1 + b0^3 >=w
        while 1 + b0 * b0 * b0 < w:
            b0 += 1
            
        a = 1
        a3 = 1
        b = b0
        b3 = b0 * b0 * b0
        count = 0 # number of ways to write w
        while a <= b:
            s = a3 + b3
            if s < w:
                a += 1 # if sum is too small, increase a
                a3 = a * a * a
            elif s == w:
                count += 1 # found a sum!
                if count > 1:
                    n -= 1
                    break
                b -= 1 # increase b both if sum too large and to find next way to write w
                b3 = b * b * b
            else:
                b -= 1 
                b3 = b * b * b
                
    return w

print (ramanujan (21))

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-24 14:41       ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-24 15:19         ` Stefan Israelsson Tampe
  2021-04-25  8:20           ` Python-on-guile Mikael Djurfeldt
  2021-04-25  8:46           ` Python-on-guile Stefan Israelsson Tampe
  0 siblings, 2 replies; 18+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-24 15:19 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 2455 bytes --]

Guile is 3x faster then fastest python-on-guile which is 2x faster then
python3 Cpython

attached is a guile corresponding program.

On Sat, Apr 24, 2021 at 4:41 PM Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> To note is that 'continue' is killing performance for python-on-guile
> programs, so by changing the
> code to not use continue lead to python-on-guile running twice the speed
> of python3. The reason is that
> the while loop is used as
> (while (...)
>    (let/ec continue
>         ...))
>
> And the let/ec is probably not optimally compiled. Python-on-guile will
> check the loop for continue usage and if not then it will skip the let/ec.
>
> I attached the code not using continue
>
> On Sat, Apr 24, 2021 at 2:59 PM Stefan Israelsson Tampe <
> stefan.itampe@gmail.com> wrote:
>
>> Actually changing in (language python compile),
>>
>> (define (letec f)
>>   (let/ec x (f x))))
>>
>> To
>>
>> (define-syntax-rule (letec f)
>>   (let/ec x (f x))))
>>
>> Actually lead to similar speeds as python3.
>>
>>
>>
>> On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
>> stefan.itampe@gmail.com> wrote:
>>
>>> Pro tip, when running this on guile the scheme code that it compilse to
>>> is located in log.txt.
>>> If you ,opt the resulting code in a guile session you might be able to
>>> pinpoint issues that
>>> delays the code execution.
>>>
>>> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
>>> wrote:
>>>
>>>> (I should perhaps add that my script doesn't benchmark the object
>>>> system but rather loops, conditionals and integer arithmetic.)
>>>>
>>>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com>
>>>> skrev:
>>>>
>>>>> Hi,
>>>>>
>>>>> Yesterday, Andy committed new code to the compiler, some of which
>>>>> concerned skipping some arity checking.
>>>>>
>>>>> Also, Stefan meanwhile committed something called "reworked object
>>>>> system" to his python-on-guile.
>>>>>
>>>>> Sorry for coming with unspecific information (don't have time to track
>>>>> down the details) but I noticed that my benchmark script written in Python,
>>>>> and which computes the 20:th Ramanujan number, now runs 60% faster than
>>>>> before these changes.
>>>>>
>>>>> This means that python-on-guile running on guile3 master executes
>>>>> python code only 2.6 times slower than the CPython python3 interpreter
>>>>> itself. :-)
>>>>>
>>>>> Have a nice weekend all,
>>>>> Mikael
>>>>>
>>>>>

[-- Attachment #2: ram.scm --]
[-- Type: text/x-scheme, Size: 1125 bytes --]

(define (ramanujan  n)
  (let lp ((w 0) (b0 1) (n n))
    (if (> n 0)
        (let ((w (+ w 1)))
          (let lp2 ((b0 b0))
            (if (< (+ 1 (* b0 b0 b0)) w)
                (lp2 (+ b0 1))
                (let lp3 ((a 1) (a3 1) (b b0) (b3 (* b0 b0 b0)) (count 0))
                  (if (<= a b)
                      (let ((s (+ a3 b3)))
                        (cond
                         ((< s w)
                          (let ((aa (+ a 1)))
                            (lp3 aa (* aa aa aa) b b3 count)))
                         ((= s w)
                          (let ((count (+ count 1)))
                            (if (> count 1)
                                (lp w b0 (- n 1))
                                (let* ((b   (- b 1))
                                       (b3  (* b b b)))
                                  (lp3 a a3 b b3 count)))))
                         (else
                          (let* ((b   (- b 1))
                                 (b3  (* b b b)))
                            (lp3 a a3 b b3 count)))))
                      (lp w b0 n))))))
        w)))

(pk (ramanujan 20))

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-24 15:19         ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-25  8:20           ` Mikael Djurfeldt
  2021-04-25 10:21             ` Python-on-guile Stefan Israelsson Tampe
  2021-04-25  8:46           ` Python-on-guile Stefan Israelsson Tampe
  1 sibling, 1 reply; 18+ messages in thread
From: Mikael Djurfeldt @ 2021-04-25  8:20 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: guile-user, guile-devel

Nice!

I guess it would be nice if "continue" *could* be compiled efficiently.
And, as you indicate, perhaps that would amount to efficiently compiling
let/ec.

Best regards,
Mikael

On Sat, Apr 24, 2021 at 5:19 PM Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> Guile is 3x faster then fastest python-on-guile which is 2x faster then
> python3 Cpython
>
> attached is a guile corresponding program.
>
> On Sat, Apr 24, 2021 at 4:41 PM Stefan Israelsson Tampe <
> stefan.itampe@gmail.com> wrote:
>
>> To note is that 'continue' is killing performance for python-on-guile
>> programs, so by changing the
>> code to not use continue lead to python-on-guile running twice the speed
>> of python3. The reason is that
>> the while loop is used as
>> (while (...)
>>    (let/ec continue
>>         ...))
>>
>> And the let/ec is probably not optimally compiled. Python-on-guile will
>> check the loop for continue usage and if not then it will skip the let/ec.
>>
>> I attached the code not using continue
>>
>> On Sat, Apr 24, 2021 at 2:59 PM Stefan Israelsson Tampe <
>> stefan.itampe@gmail.com> wrote:
>>
>>> Actually changing in (language python compile),
>>>
>>> (define (letec f)
>>>   (let/ec x (f x))))
>>>
>>> To
>>>
>>> (define-syntax-rule (letec f)
>>>   (let/ec x (f x))))
>>>
>>> Actually lead to similar speeds as python3.
>>>
>>>
>>>
>>> On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
>>> stefan.itampe@gmail.com> wrote:
>>>
>>>> Pro tip, when running this on guile the scheme code that it compilse to
>>>> is located in log.txt.
>>>> If you ,opt the resulting code in a guile session you might be able to
>>>> pinpoint issues that
>>>> delays the code execution.
>>>>
>>>> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
>>>> wrote:
>>>>
>>>>> (I should perhaps add that my script doesn't benchmark the object
>>>>> system but rather loops, conditionals and integer arithmetic.)
>>>>>
>>>>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com>
>>>>> skrev:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Yesterday, Andy committed new code to the compiler, some of which
>>>>>> concerned skipping some arity checking.
>>>>>>
>>>>>> Also, Stefan meanwhile committed something called "reworked object
>>>>>> system" to his python-on-guile.
>>>>>>
>>>>>> Sorry for coming with unspecific information (don't have time to
>>>>>> track down the details) but I noticed that my benchmark script written in
>>>>>> Python, and which computes the 20:th Ramanujan number, now runs 60% faster
>>>>>> than before these changes.
>>>>>>
>>>>>> This means that python-on-guile running on guile3 master executes
>>>>>> python code only 2.6 times slower than the CPython python3 interpreter
>>>>>> itself. :-)
>>>>>>
>>>>>> Have a nice weekend all,
>>>>>> Mikael
>>>>>>
>>>>>>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-24 15:19         ` Python-on-guile Stefan Israelsson Tampe
  2021-04-25  8:20           ` Python-on-guile Mikael Djurfeldt
@ 2021-04-25  8:46           ` Stefan Israelsson Tampe
  1 sibling, 0 replies; 18+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-25  8:46 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

The remaining 3x between guile and python can be to either the extensive
usage of set! in python or if the number of runs in the inner loop is small
because there is a let/ec for the break and according to the standard
a catch to support the raising of StopIteration. Set! probably cannot
account for 3x speedwise, but it may
hinder optimisations that may yield a speedup of that factor.

On Sat, Apr 24, 2021 at 5:19 PM Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> Guile is 3x faster then fastest python-on-guile which is 2x faster then
> python3 Cpython
>
> attached is a guile corresponding program.
>
> On Sat, Apr 24, 2021 at 4:41 PM Stefan Israelsson Tampe <
> stefan.itampe@gmail.com> wrote:
>
>> To note is that 'continue' is killing performance for python-on-guile
>> programs, so by changing the
>> code to not use continue lead to python-on-guile running twice the speed
>> of python3. The reason is that
>> the while loop is used as
>> (while (...)
>>    (let/ec continue
>>         ...))
>>
>> And the let/ec is probably not optimally compiled. Python-on-guile will
>> check the loop for continue usage and if not then it will skip the let/ec.
>>
>> I attached the code not using continue
>>
>> On Sat, Apr 24, 2021 at 2:59 PM Stefan Israelsson Tampe <
>> stefan.itampe@gmail.com> wrote:
>>
>>> Actually changing in (language python compile),
>>>
>>> (define (letec f)
>>>   (let/ec x (f x))))
>>>
>>> To
>>>
>>> (define-syntax-rule (letec f)
>>>   (let/ec x (f x))))
>>>
>>> Actually lead to similar speeds as python3.
>>>
>>>
>>>
>>> On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
>>> stefan.itampe@gmail.com> wrote:
>>>
>>>> Pro tip, when running this on guile the scheme code that it compilse to
>>>> is located in log.txt.
>>>> If you ,opt the resulting code in a guile session you might be able to
>>>> pinpoint issues that
>>>> delays the code execution.
>>>>
>>>> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
>>>> wrote:
>>>>
>>>>> (I should perhaps add that my script doesn't benchmark the object
>>>>> system but rather loops, conditionals and integer arithmetic.)
>>>>>
>>>>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com>
>>>>> skrev:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Yesterday, Andy committed new code to the compiler, some of which
>>>>>> concerned skipping some arity checking.
>>>>>>
>>>>>> Also, Stefan meanwhile committed something called "reworked object
>>>>>> system" to his python-on-guile.
>>>>>>
>>>>>> Sorry for coming with unspecific information (don't have time to
>>>>>> track down the details) but I noticed that my benchmark script written in
>>>>>> Python, and which computes the 20:th Ramanujan number, now runs 60% faster
>>>>>> than before these changes.
>>>>>>
>>>>>> This means that python-on-guile running on guile3 master executes
>>>>>> python code only 2.6 times slower than the CPython python3 interpreter
>>>>>> itself. :-)
>>>>>>
>>>>>> Have a nice weekend all,
>>>>>> Mikael
>>>>>>
>>>>>>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
  2021-04-23 20:41 ` Python-on-guile Linus Björnstam
  2021-04-24 10:04 ` Python-on-guile Mikael Djurfeldt
@ 2021-04-25 10:18 ` Stefan Israelsson Tampe
  2021-04-27 12:29 ` Python-on-guile Nala Ginrut
  3 siblings, 0 replies; 18+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-25 10:18 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

Python List lookup is 2x slower now than cpython. Tuple lookup is slightly
faster.

On Fri, 23 Apr 2021, 17:01 Mikael Djurfeldt <mikael@djurfeldt.com> wrote:

> Hi,
>
> Yesterday, Andy committed new code to the compiler, some of which
> concerned skipping some arity checking.
>
> Also, Stefan meanwhile committed something called "reworked object system"
> to his python-on-guile.
>
> Sorry for coming with unspecific information (don't have time to track
> down the details) but I noticed that my benchmark script written in Python,
> and which computes the 20:th Ramanujan number, now runs 60% faster than
> before these changes.
>
> This means that python-on-guile running on guile3 master executes python
> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>
> Have a nice weekend all,
> Mikael
>
>

[-- Attachment #2: Type: text/html, Size: 1251 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-25  8:20           ` Python-on-guile Mikael Djurfeldt
@ 2021-04-25 10:21             ` Stefan Israelsson Tampe
  0 siblings, 0 replies; 18+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-25 10:21 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

It is not the break let/ex that slows it down. But for wha it's worth we do
not do a let/ec if no break is used. Now.

On Sun, 25 Apr 2021, 10:20 Mikael Djurfeldt <mikael@djurfeldt.com> wrote:

> Nice!
>
> I guess it would be nice if "continue" *could* be compiled efficiently.
> And, as you indicate, perhaps that would amount to efficiently compiling
> let/ec.
>
> Best regards,
> Mikael
>
> On Sat, Apr 24, 2021 at 5:19 PM Stefan Israelsson Tampe <
> stefan.itampe@gmail.com> wrote:
>
>> Guile is 3x faster then fastest python-on-guile which is 2x faster then
>> python3 Cpython
>>
>> attached is a guile corresponding program.
>>
>> On Sat, Apr 24, 2021 at 4:41 PM Stefan Israelsson Tampe <
>> stefan.itampe@gmail.com> wrote:
>>
>>> To note is that 'continue' is killing performance for python-on-guile
>>> programs, so by changing the
>>> code to not use continue lead to python-on-guile running twice the speed
>>> of python3. The reason is that
>>> the while loop is used as
>>> (while (...)
>>>    (let/ec continue
>>>         ...))
>>>
>>> And the let/ec is probably not optimally compiled. Python-on-guile will
>>> check the loop for continue usage and if not then it will skip the let/ec.
>>>
>>> I attached the code not using continue
>>>
>>> On Sat, Apr 24, 2021 at 2:59 PM Stefan Israelsson Tampe <
>>> stefan.itampe@gmail.com> wrote:
>>>
>>>> Actually changing in (language python compile),
>>>>
>>>> (define (letec f)
>>>>   (let/ec x (f x))))
>>>>
>>>> To
>>>>
>>>> (define-syntax-rule (letec f)
>>>>   (let/ec x (f x))))
>>>>
>>>> Actually lead to similar speeds as python3.
>>>>
>>>>
>>>>
>>>> On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
>>>> stefan.itampe@gmail.com> wrote:
>>>>
>>>>> Pro tip, when running this on guile the scheme code that it compilse
>>>>> to is located in log.txt.
>>>>> If you ,opt the resulting code in a guile session you might be able to
>>>>> pinpoint issues that
>>>>> delays the code execution.
>>>>>
>>>>> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <
>>>>> mikael@djurfeldt.com> wrote:
>>>>>
>>>>>> (I should perhaps add that my script doesn't benchmark the object
>>>>>> system but rather loops, conditionals and integer arithmetic.)
>>>>>>
>>>>>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com>
>>>>>> skrev:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Yesterday, Andy committed new code to the compiler, some of which
>>>>>>> concerned skipping some arity checking.
>>>>>>>
>>>>>>> Also, Stefan meanwhile committed something called "reworked object
>>>>>>> system" to his python-on-guile.
>>>>>>>
>>>>>>> Sorry for coming with unspecific information (don't have time to
>>>>>>> track down the details) but I noticed that my benchmark script written in
>>>>>>> Python, and which computes the 20:th Ramanujan number, now runs 60% faster
>>>>>>> than before these changes.
>>>>>>>
>>>>>>> This means that python-on-guile running on guile3 master executes
>>>>>>> python code only 2.6 times slower than the CPython python3 interpreter
>>>>>>> itself. :-)
>>>>>>>
>>>>>>> Have a nice weekend all,
>>>>>>> Mikael
>>>>>>>
>>>>>>>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-24 12:59     ` Python-on-guile Stefan Israelsson Tampe
  2021-04-24 14:41       ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-25 10:54       ` Dr. Arne Babenhauserheide
  2021-04-25 11:54         ` Python-on-guile Vivien Kraus via General Guile related discussions
  1 sibling, 1 reply; 18+ messages in thread
From: Dr. Arne Babenhauserheide @ 2021-04-25 10:54 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]


Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:

> (define-syntax-rule (letec f)
>   (let/ec x (f x))))
>
> Actually lead to similar speeds as python3.

Please keep in mind that this is math. There are parts of Python that
are heavily optimized, for example reading strings from disk. Guile will
likely have a hard time to compete with that.

But for math Guile is quite a bit faster than Python :-)

(next frontier: compete with math that’s implemented via numpy — you
can find RPython implementations of the basics of numpy in the
pypy-sources:
https://foss.heptapod.net/pypy/pypy/-/tree/branch/default/pypy/module/micronumpy
)

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-25 10:54       ` Python-on-guile Dr. Arne Babenhauserheide
@ 2021-04-25 11:54         ` Vivien Kraus via General Guile related discussions
  0 siblings, 0 replies; 18+ messages in thread
From: Vivien Kraus via General Guile related discussions @ 2021-04-25 11:54 UTC (permalink / raw)
  To: Dr. Arne Babenhauserheide, Stefan Israelsson Tampe
  Cc: guile-user, guile-devel

Hello,

Le dimanche 25 avril 2021 à 12:54 +0200, Dr. Arne Babenhauserheide a
écrit :
> (next frontier: compete with math that’s implemented via numpy — you
> can find RPython implementations of the basics of numpy in the
> pypy-sources:
> https://foss.heptapod.net/pypy/pypy/-/tree/branch/default/pypy/module/micronumpy
> )

I think it would be wiser to use guile arrays to implement the same
things as numpy.




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Python-on-guile
  2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
                   ` (2 preceding siblings ...)
  2021-04-25 10:18 ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-27 12:29 ` Nala Ginrut
  3 siblings, 0 replies; 18+ messages in thread
From: Nala Ginrut @ 2021-04-27 12:29 UTC (permalink / raw)
  To: mikael; +Cc: guile-user, guile-devel

Nice to know it!
I still don't have time to polish my guile-lua-rebirth. Anyway, it's really
good news to see the transpiler has a good performance on Guile.!

Best regards.


On Fri, Apr 23, 2021 at 11:01 PM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

> Hi,
>
> Yesterday, Andy committed new code to the compiler, some of which
> concerned skipping some arity checking.
>
> Also, Stefan meanwhile committed something called "reworked object system"
> to his python-on-guile.
>
> Sorry for coming with unspecific information (don't have time to track
> down the details) but I noticed that my benchmark script written in Python,
> and which computes the 20:th Ramanujan number, now runs 60% faster than
> before these changes.
>
> This means that python-on-guile running on guile3 master executes python
> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>
> Have a nice weekend all,
> Mikael
>
>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* python-on-guile
@ 2022-02-19 19:36 Stefan Israelsson Tampe
  0 siblings, 0 replies; 18+ messages in thread
From: Stefan Israelsson Tampe @ 2022-02-19 19:36 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2220 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-02-19 19:36 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
2021-04-23 20:41 ` Python-on-guile Linus Björnstam
2021-04-24 10:04 ` Python-on-guile Mikael Djurfeldt
2021-04-24 11:26   ` Python-on-guile Stefan Israelsson Tampe
2021-04-24 12:59     ` Python-on-guile Stefan Israelsson Tampe
2021-04-24 14:41       ` Python-on-guile Stefan Israelsson Tampe
2021-04-24 15:19         ` Python-on-guile Stefan Israelsson Tampe
2021-04-25  8:20           ` Python-on-guile Mikael Djurfeldt
2021-04-25 10:21             ` Python-on-guile Stefan Israelsson Tampe
2021-04-25  8:46           ` Python-on-guile Stefan Israelsson Tampe
2021-04-25 10:54       ` Python-on-guile Dr. Arne Babenhauserheide
2021-04-25 11:54         ` Python-on-guile Vivien Kraus via General Guile related discussions
2021-04-25 10:18 ` Python-on-guile Stefan Israelsson Tampe
2021-04-27 12:29 ` Python-on-guile Nala Ginrut
  -- strict thread matches above, loose matches on Subject: below --
2022-02-19 19:36 python-on-guile Stefan Israelsson Tampe
2019-06-14 18:06 python-on-guile Stefan Israelsson Tampe
2019-06-22 21:07 ` python-on-guile Arne Babenhauserheide
2019-06-26 18:45 ` python-on-guile Nala Ginrut

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).