merits of Lisp vs Python

Alex Mizrahi udodenko at users.sourceforge.net
Sun Dec 10 18:05:39 EST 2006


(message (Hello 'Paul)
(you :wrote  :on '(10 Dec 2006 10:07:12 -0800))
(

 PR> There would be terrible performance penalties dealing with the
 PR> environment lookup on every lexical variable reference.

LOL! you're saying it in Python newsgroup!
do you know that python makes a dict lookup on each access to global 
variable/function/builtin?
and it does dict lookup for each object's method/field access.

and actually we can use vectors rather than dicts for lexical environments, 
so it will be much faster.
and if you call that "terrible penalties", how will you call python's 
performace? i don't know which adjective can express it then..

 PR> That's the point.  The compiler would treat those as references to
 PR> slots in the call frame, would do type inference so it could use
 PR> unboxed atoms where it could, etc.  You'd lose all that.

i think there can be some optimizations (we need lex env object only where 
we need a closure, i think), but right -- to have best performance, you'll 
need to implement it in the language level. but you can get functionality 
working right, and with acceptable performance.
if python's performance is acceptable for you, why other interpreter's won't 
be?

 ??>> why do you think so?
 ??>> you know some case that does not work with call/cc?

 PR> I don't see how to implement coroutines with CL macros.  Maybe I'm
 PR> missing something.

read the book.

i can give you a basic idea:

* (macroexpand '(with-call/cc (print 1) (call/cc (lambda (k1) k1)) (print 
2)))

(DRIVE-CPS
 (PROGN
  (PRINT 1)
  (LAMBDA ()
    (FUNCALL #'TOPLEVEL-K
             (FUNCALL #'(LAMBDA (K1) K1)
                      (MAKE-CALL/CC-K
                       (LAMBDA (#:V-1712)
                         (DECLARE (IGNORE #:V-1712))
                         (LAMBDA ()
                           (FUNCALL #'TOPLEVEL-K (PROGN (PRINT 2)))))))))))

you see that it makes a cut in call/cc point -- continuous blocks are not 
affected with the transform.

 ??>> and then use call/cc as i've shown in
 ??>> example. that's real generators. there's no need for any cond -- you
 ??>> can save state as current-continuation.

 PR> Fully general call/cc has to be able to switch from one execution
 PR> stack to another and back.

that's from imperative point of view.

but once you convert it to CPS, you just operate with closures. stack is 
just a lexical variables caught into closure.
do you know what does CPS mean at all??

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"People who lust for the Feel of keys on their fingertips (c) Inity") 





More information about the Python-list mailing list