stackless python

Justin Sheehy justin at iago.org
Wed Jan 2 13:52:47 EST 2002


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

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