On Feb 5, 9:30 am, [EMAIL PROTECTED] wrote: > I don't know the exact details but I think the issue is the dynamic > nature of Python makes it impossible to correctly store the various > types and changes into compiled code. Someone else will probably be > able to provide a good reason as to why it isn't very feasible, nor a > good idea. If you want to speed up your python look at Psyco. > http://psyco.sourceforge.net/
Yeah, but exactly what features make it so hard to write a compiler for Python? Common Lisp seems like a language at least as dynamic as Python, e.g. you can change the type of objects at runtime, you can make changes to functions, you can change classes at runtime, you can add methods and generic functions (nb. these changes are reflected in existing objects), you have a metaobject protocol. Moreover, you have multimethods (in Python you don't, so it is one less thing to care). However, Common Lisp has a few decent compilers (at least two open source and two commercial). Google tells me that such arguments have been raised back in 2001 [1]. I can add from myself that today Python is much more similar to Common Lisp than in 2001. For example, multiple inheritance in Python >= 2.3 behaves like in Dylan, which in turn behaves like CLOS with a twist. What is more, apparently there is a Python compiler via CL: CLPython (I don't have access to ACL, however, so I can't verify the claims of the authors). Finally, speaking of JIT compilers: recently has appeared something that looks like avery nice JIT compiler for Scheme, Ikarus [3]. Scheme is also quite dynamical, but is not OO, so I don't know how viable is the analogy. Of course, when writing Python extensions in C is fairly easy and when rewriting just the critical part of the code is enough to get acceptable performance, I really doubt I will see anybody willing to invest serious amounts of money and time into writing a native compiler for Python. Learning C cannot be so hard ;-). Also, this seems consistent with Python viewed as a glue between libraries written in C. Cheers, -- Richard BIG FAT DISCLAIMER: I DO NOT want to start a "Python vs. Common Lisp and Scheme" flame war. [1] http://mail.python.org/pipermail/python-list/2001-April/080394.html [2] http://common-lisp.net/project/clpython/ [3] http://www.cs.indiana.edu/~aghuloum/ikarus/ -- http://mail.python.org/mailman/listinfo/python-list