[Tutor] General Programming Question
alan.gauld@bt.com
alan.gauld@bt.com
Thu, 28 Jun 2001 10:43:54 +0100
> I'd like to know if there was a way to compile Python to
> native machine code,
Of course its possible to do this since *every* program you run
runs as native machine code - there aint no other way! But in Pythons
case the native machine code of the interpreter is translating the
program as it goes... To build a truly native code compiler for
Python would be intensely difficult given Pythons very dynamic
nature - we can construct code based on user input and then execute
it - you need the interpreter functionality builtb into every
program anyway!
> would it run as fast as say C++ or Java?
Given the above even if you built a native code compiler its
speed would depend on how the author wrote the program - if it
used dynamic code generation then no - OTOH you can't write
that kind of code at all in Java or C++!
BUT in my informal tests Python is very oftenb as fast, or faster
than Java so thats not an issue. It is however significantly slower
than C++ (just as Java is - about 5-10 times depending on JVMs etc).
Alan G