guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: speedup of modifying return values


From: Hans Åberg
Subject: Re: speedup of modifying return values
Date: Wed, 29 Aug 2018 22:54:56 +0200


> On 29 Aug 2018, at 20:46, Taylan Kammer <address@hidden> wrote:
> 
> Stefan Israelsson Tampe <address@hidden> writes:
> 
>> Hi all, I'm trying to make a python clone in guile. Currently the code is 
>> slow and one of  the reasons is the following,
>> 
>> in my pythoon
>> 
>> return 1,2
>> 
>> returns a (values 1 2) in order to get python and scheme to interoperate. 
>> but for python if you use
>> 
>> x = 1,2
>> 
>> then x is the tupple '(1 2) and in guile it is 1. So therefore we wrap the 
>> result for
>> 
>> x=f(10)
>> 
>> as
>> (set! x (call-with-values (lambda () (f x)) (case-lambda ((x) x) (x x))))
>> 
>> This can be compiled to efficient bytecode but is not done so in guile. In 
>> stead a closure is created at each assignment site and creating ineficient 
>> code.
>> 
>> Any ideas how to improve this (I don't want "return a,b" to mean (list a b) 
>> which is a quick solution
>> if we want to just stay in python and not interoperate with scheme at all on 
>> this level.
> 
> Sounds like a fun project. :-)
> 
> Idea:
> 
> Make Python tuples a new data type, instead of multi-values.
> 
> The fact that they can be stored in a single storage location in Python
> means that they are actually a data type, only special-handled for
> automatic destructuring in some places...

Indeed, the problem is that in Scheme, (list f x₀ …), using normal infix tuple 
notation, creates the deferred function object f(x₀, …), and I found it hard to 
write a normal function call language on top of that.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]