stackless python

Bengt Richter bokr at accessone.com
Wed Jan 2 23:41:59 CET 2002


On Wed, 02 Jan 2002 13:52:47 -0500, Justin Sheehy <justin at iago.org> wrote:

>Michael Hudson <mwh at python.net> writes:
>
>>> The thing I don't fully understand is that several Scheme
>>> implementations are both smaller and faster than Python.
>>
>> Less dynamism, I think.  I'm not sure what the standard says about
>> things like
>>
>> (define (func x y) (+ x y))
>> (set! + -)
>> (display (func 2 3))
>>
>> but I'd bet at least some implementations would print "5".
>
FWIW, here's an oldie (came on 5 1/4" floppy in "PC Scheme Trade Edition" book
from MIT press 1990, by Texas Instruments)

Note the difference in results at [3] and [4]:
_________________________________________

PC Scheme Student Edition 3.0
(C) Copyright 1987 by Texas Instruments
          All Rights Reserved.

[PCS-DEBUG-MODE is OFF]
[1] (define (func x y) (+ x y))
FUNC
[2] (set! + -)
[WARNING: modifying an `integrable' variable: +]
#<PROCEDURE ->
[3] (display (func 2 3))
5
[4] (+ 2 3)
-1
[5]
_________________________________________

>It's hard to show that _none_ of them do that, but on the ones I have handy:
>
>----
>Chez Scheme Version 6.1
>Copyright (c) 1998 Cadence Research Systems
>
>> (define (func x y) (+ x y)) 
>> (set! + -) 
>> (display (func 2 3)) 
>-1
>----
>Welcome to MzScheme version 103, Copyright (c) 1995-2000 PLT (Matthew Flatt)
>> (define (func x y) (+ x y))
>> (set! + -)
>> (display (func 2 3))
>-1
>----
>$ elk
>> (define (func x y) (+ x y))
>func
>> (set! + -)
>#[primitive +]
>> (display (func 2 3))
>-1
>----
>(mit scheme)
>1 ]=> (define (func x y) (+ x y))
>
>;Value: func
>
>1 ]=> (set! + -)
>
>;Value 1: #[arity-dispatched-procedure 1]
>
>1 ]=> (display (func 2 3))
>-1
>;Unspecified return value
>----
>guile> (define (func x y) (+ x y))
>guile> (set! + -)
>guile> (display (func 2 3))
>-1
>----
>
>At least a good portion of Scheme implementations support this level
>of dynamism.  At least a couple of those are pretty darn efficient
>compared to CPython.  So I'd venture that while there may be "less
>dynamism" in some real sense, it isn't as simple a difference as you imply.
>
>-Justin
>
> 
>p.s. - I suspect that scheme48 might not let you assign to "+", from
>       what I remember of it.  
>
>
>




More information about the Python-list mailing list